13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

314 Co-operating Processes Chapter 9context switches from process to kernel and back are less expensive than a processswitch from one process to another.A decision to embed a service in the kernel carries a price of inflexibility (there is noalternative to using the provided service) and potential inadequacy (the provided servicemay not fit the needs of all its customers). For this reason, shared resources are usuallymanaged not by the kernel but by separate processes. This design holds even forhardware resources like magnetic disk.Part of the goal of the communication-kernel approach is to keep the kernel assmall as possible. Therefore, it is restricted to provide mechanisms (and not policies) forthree purposes:ProcessesMain-store managementInter-process communication.All matters of policy are relegated to processes.Processes can be classified as servers or clients. A typical application program isa client that makes calls on servers for file access and other forms of transput. A clientwith regard to one conversation might well be a server with regard to another.Whether a particular process is on one machine or another of a multicomputer isusually immaterial, except for servers that need to access physical devices. Specialprocesses decide on which machine to place each new process and whether to migratethe process during its execution. That is, the resources of time and space are managed byservers written for that purpose.4.1 Processes and threadsA process is an entity that corresponds to a virtual space. Creating a process involvesallocating the necessary amount of space and loading it with a program. Creating anddestroying processes is relatively expensive. The kernel needs to be involved only in theestablishment of mapping tables and process control blocks. The loader can be an ordinaryprocess that determines how much virtual space is needed and initializes it by readingthe appropriate load image.The active entities that inhabit a process are called threads. When a process isfirst created, a single thread begins to execute. New threads within a process can becreated either by internal events (an existing thread spawns a new one) or by externalevents (a message arrives at the process that causes a new thread to be formed). Creatingand destroying threads is relatively inexpensive.All threads within a process potentially share the entire virtual store of that process.Sharing may be controlled, however, either by programming language support or,more expensively, by kernel efforts.The threads that inhabit a process may execute simultaneously, particularly on amultiprocessor. In this case, the kernel might provide simple synchronization mechanisms(like semaphores) to allow the threads to protect shared data. However, experiencewith the Lynx programming language has shown the benefits of preventing a thread from

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!