Classical Problems of Synchronization

In this tutorial, we will discuss the various classical problems of process synchronization.

Semaphore can be used in other synchronization problems besides Mutual Exclusion.

Below are some of the classical problems depicting flaws of process synchronization in systems where cooperating processes are present.

We will discuss the following three problems:

  1. Bounded Buffer (Producer-Consumer) Problem

  2. Dining Philosophers Problem

  3. The Readers Writers Problem

Bounded Buffer Problem

Because the buffer pool has a maximum size, this problem is often called the Bounded buffer problem.

  • This problem is generalized in terms of the Producer-Consumer problem, where a finite buffer pool is used to exchange messages between producer and consumer processes.

  • The solution to this problem is, creating two counting semaphores "full" and "empty" to keep track of the current number of full and empty buffers respectively.

  • This Producers mainly produce a product and consumers consume the product, but both can use one of the containers each time.

  • The main complexity of this problem is that we must have to maintain the count for both empty and full containers that are available.

Dining Philosophers Problem

  • The dining philosopher's problem involves the allocation of limited resources to a group of processes in a deadlock-free and starvation-free manner.

  • There are five philosophers sitting around a table, in which there are five chopsticks/forks kept beside them and a bowl of rice in the center, When a philosopher wants to eat, he uses two chopsticks - one from their left and one from their right. When a philosopher wants to think, he keeps down both chopsticks at their original place.

The Readers Writers Problem

  • In this problem, there are some processes(called readers) that only read the shared data, and never change it, and there are other processes(called writers) that may change the data in addition to reading, or instead of reading it.

  • There is various type of readers-writers problems, most centered on relative priorities of readers and writers.

  • The main complexity of this problem occurs from allowing more than one reader to access the data at the same time.