Inter-Process Communicationby Xiaolan Liu |
|
Solutions
Problems
|
Examples
of IPC Problem
Producer/Consumer and Readers/Writers are two classic problems in inter-process communication. Producer/Consumer: The producer/consumer problem is a classic synchronization problem. In this problem, two processes (producer/consumer) share a fixed-size buffer. One process produces information and puts it in the buffer. The other process consumes information from the buffer. So, the two processes work as follows: Producer: Step1: Produce an item Step2: If buffer is full, go to sleep Step3: Otherwise, put the item into buffer Consumer: Step1: If buffer is empty, go to sleep Step2: Take item from buffer Step3: Consume the item Readers/Writers: In Readers/Writers problem, two set of processes share a common database. The readers read a value from the database and the writers writes a value into the database. Only one writer can write to the database at a time meanwhile no readers are allowed to read from database. However, one or more readers may be reading from the database at the same time. When the readers are reading from database, no writers are allowed to write into database.
Both problems can be implemented by the following three solutions: Semaphores, Monitors, and Message Passing.
|