Sleeping Barber Problem
Sleeping Barber Problem
PROBLEM
A CLASSICINTER-PROCESS COMMUNICATION
&SYNCHRONIZATIONPROBLEM
BETWEEN MULTIPLEOPERATING
SYSTEMPROCESSES
PROBLEMS
Both barber and customer waits for each other :
o customer arrives - barber is busy
o Customer on his way to waiting room, barber finishes hair cut.
o Barber goes to sleep, Customer waits.
SOLUTION
Mutex :
Ensures that only one of the participants can change
state at once.
The barber must acquire this mutex before checking for
customers and release it when he begins either to sleep
or cut hair.
A customer must acquire it before entering the shop and
release it once he is sitting in either a waiting chair or the
barber chair.
6
PSEUDOCODE
THANK YOU..