/    /  OS – Classical Problems of Synchronization

Classical Problems of Synchronization

 

The classical problems of synchronization are as follows:

  1. Bound-Buffer problem
  2. Sleeping barber problem
  3. Dining Philosophers problem
  4. Readers and writers problem

 

Bound-Buffer problem

Also known as the Producer-Consumer problem. In this problem, there is a buffer of n slots, and each buffer is capable of storing one unit of data. There are two processes that are operating on the buffer – Producer and Consumer. The producer tries to insert data and the consumer tries to remove data. 

If the processes are run simultaneously they will not yield the expected output.

The solution to this problem is creating two semaphores, one full and the other empty to keep a track of the concurrent processes. 

 

Sleeping Barber Problem

This problem is based on a hypothetical barbershop with one barber. 

When there are no customers the barber sleeps in his chair. If any customer enters he will wake up the barber and sit in the customer chair. If there are no chairs empty they wait in the waiting queue.

 

Dining Philosopher’s problem

This problem states that there are K number of philosophers sitting around a circular table with one chopstick placed between each pair of philosophers. The philosopher will be able to eat if he can pick up two chopsticks that are adjacent to the philosopher. 

This problem deals with the allocation of limited resources. 

 

Readers and Writers Problem

This problem occurs when many threads of execution try to access the same shared resources at a time. Some threads may read, and some may write. In this scenario, we may get faulty outputs. 

 

Reference 

Classical Problems of Synchronization