Process Synchronization
80 likes | 498 Vues
Process Synchronization. Cooperating Processes. Process Cooperation Purposes Information sharing (Share files) Computation speedup (create subtasks to run simultaneously) Modularity (system function divide into separate processes or threads)
Process Synchronization
E N D
Presentation Transcript
Process Synchronization Cooperating Processes Process Cooperation Purposes • Information sharing (Share files) • Computation speedup (create subtasks to run simultaneously) • Modularity (system function divide into separate processes or threads) • Convenience (Run several tasks of the same user in the same environment at the same time)
Inter process communication (IPC) mechanisms • Concurrent execution of cooperating processes requires mechanisms • that allow processes to communicate with one another • and to synchronize their actions. • Cooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data and information to communicate and to synchronize. • OS provides those IPC mechanisms.
IPC models There are two fundamental models of interprocess communication: (1) shared memory and (2) message passing. • In the shared-memorymodel • 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. • In the message passingmodel • communication takes place by means of messages exchanged between the cooperating processes.
IPC models Communications models. (a) Message passing. (b) Shared memory.
IPC models. Tradeoff. • Shared Memory • Maximum speed (memory operations) • Convenience for sharing between local processes (simple write/read) • Difficult to implement for Inter Computer sharing or communication (needs polling). • Message Passing • Slow speed • (system calls, kernel intervention) • Complex to implement for inter process sharing. • data is sent by message • Easier to implement for Inter Process and Inter Computer communication / synchronization Communications models. (a) Message passing. (b) Shared memory.
Producer Consumer paradigm • A producer process producesinformation • that is consumed by a consumer process. • The producer and consumer must be synchronized. • Web server produces HTML files and images which are consumed by the client • print program produces characters that are consumed by the printer driver
Producer Consumer paradigmneeds synchronization The unbounded-buffer producer-consumer problem places no practical limit on the size of the buffer. Waiting means - Synchronization
Producer Consumer paradigmmore synchronization The bounded-buffer assumes a fixed buffer size. The Bounded Buffer Problem - to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.