A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes
2 A. Frank - P. Weisberg Cooperating Processes • Introduction to Cooperating Processes • Producer/Consumer Problem • The Critical-Section Problem • Synchronization Hardware • Semaphores
3 A. Frank - P. Weisberg Introduction to Cooperating Processes • Processes within a system may be independent or cooperating. • Independent process cannot affect or be affected by the execution of another process. • Cooperating process can affect or be affected by other processes, including sharing data. • Reasons for cooperating processes: – Information sharing – Computation speed-up – Modularity – Convenience
4 Cooperation Models
5 A. Frank - P. Weisberg Cooperation among Processes by Sharing • Processes use and update shared data such as shared variables, memory, files, and databases. • Writing must be mutually exclusive to prevent a race condition leading to inconsistent data views. • Critical sections are used to provide this data integrity. • A process requiring the critical section must not be delayed indefinitely; no deadlock or starvation.
6 A. Frank - P. Weisberg Cooperation among Processes by Communication • Communication by messages provides a way to synchronize, or coordinate, the various activities. • Possible to have deadlock – – each process waiting for a message from the other process. • Possible to have starvation – – two processes sending a message to each other while another process waits for a message.
7 A. Frank - P. Weisberg Producer/Consumer (P/C) Problem (1 ( • Paradigm for cooperating processes – Producer process produces information that is consumed by a Consumer process. – Example 1: a print program produces characters that are consumed by a printer. – Example 2: an assembler produces object modules that are consumed by a loader.
8 A. Frank - P. Weisberg Producer/Consumer (P/C) Problem (2 ( • We need a buffer to hold items that are produced and later consumed: – unbounded-buffer places no practical limit on the size of the buffer.
You've reached the end of your free preview.
Want to read all 29 pages?
- Summer '18
- Race condition, Concurrent computing, P. Weisberg, A. Frank