- Processes executing concurrently in the OS may be either independent processes or cooperating processes.
- A process is independent if it cannot affect or be affected by the other processes executing in the system. Any process that does not share data with any other process is independent.
- A process is cooperating if it can affect or be affected by the other processes executing in the system. Clearly, any process that shares data with other processes is a cooperating process.
- There are several reasons for providing an environment that allows process cooperation:
- Information sharing. Since several users may be interested in the same piece of information (for instance, a shared file), we must provide an environment to allow concurrent access to such information.
- Computation speedup. If we want a particular task to run faster, we must break it into subtasks, each of which will be executing in parallel with the others. Notice that such a speedup can be achieved only if the computer has multiple processing elements (such as CPUs or I/O channels).
- Modularity. We may want to construct the system in a modular fashion, dividing the system functions into separate processes or threads.
- Convenience. Even an individual user may work on many tasks at the same time. For instance, a user may be editing, printing, and compiling in parallel.
- Cooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data and information.
- There are two fundamental models of interprocess communication:
- Shared Memory. A region of memory that is shared by cooperating processes is established. Processes can then exchange
information by reading and writing data to the shared region.
- Message Passing. Communication takes place by means of messages exchanged between the cooperating processes. The two communications models are contrasted in Fig. 3.13.
Figure 3.13:
Communications models. (a) Message passing. (b) Shared memory.
|
- Both of the models just discussed are common in OSs, and many systems implement both.
- Message passing is useful for exchanging smaller amounts of data, because no conflicts need be avoided. Message passing is also easier to implement than is shared memory for intercomputer communication.
- Shared memory allows maximum speed and convenience of communication, as it can be done at memory speeds when within a computer.
Shared memory is faster than message passing, as message-passing systems are typically implemented using system calls and thus require the more time-consuming task of kernel intervention.
- In contrast, in shared-memory systems, system calls are required only to establish shared-memory regions. Once shared memory is established, all accesses are treated as routine memory accesses, and no assistance from the kernel is required.
Subsections
Cem Ozdogan
2011-02-14