Process Synchronization

Resource sharing is not the only area of concern in multiprogramming systems. Synchronization is an important problem in InterProcess Communication. Consider the following example, in which two processes, running concurrently, are sharing a bounded buffer. One process is producing items to place in the buffer, while another process is consuming the items in the buffer.

 buffer[10]              // buffer of size 10

  Producer process-

  while (true)           // loop forever
    produce (item)       // create a new item
    enter_item (item)    // place item in buffer

  Consumer process-

  while (true)           // loop forever
    remove_item (item)   // remove an item from the buffer

Here, the producer process must not be allowed to place an item in the buffer unless an empty slot in the buffer exists. Conversely, the consumer must not be allowed to remove an item from the buffer unless an item exists. This example illustrates the need for synchronization between processes. This means that a certain sequence of events must not be allowed to happen. Synchronization is different from mutual exclusion, in that synchronization would not prevent the producer and consumer from accessing the buffer at the same time.


             
IPC Home   Subway    Process     Resource 
  Page      Map    Interaction   Sharing