0% found this document useful (0 votes)
71 views1 page

Sleeping Barber Problem

The document describes the Sleeping Barber problem, where a barber shop has one barber who cuts customers' hair or sleeps in his chair when no customers are waiting. Customers can either wake the barber if he's sleeping or sit in the waiting room if he's cutting hair. However, the problem aims to illustrate scheduling issues that can arise from this scenario.

Uploaded by

Vinay Jacob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views1 page

Sleeping Barber Problem

The document describes the Sleeping Barber problem, where a barber shop has one barber who cuts customers' hair or sleeps in his chair when no customers are waiting. Customers can either wake the barber if he's sleeping or sit in the waiting room if he's cutting hair. However, the problem aims to illustrate scheduling issues that can arise from this scenario.

Uploaded by

Vinay Jacob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Flow chart for Sleeping barber problem:

The Sleeping Barber Problem is often attributed to Edsger Dijkstra (1965), one of the pioneers in computer science.

Problem Statement
The analogy is based upon a hypothetical barber shop with one barber. The barber has one barber
chair and a waiting room with a number of chairs in it. When the barber finishes cutting a
customer's hair, he dismisses the customer and then goes to the waiting room to see if there are
other customers waiting. If there are, he brings one of them back to the chair and cuts his hair. If
there are no other customers waiting, he returns to his chair and sleeps in it.

Each customer, when he arrives, looks to see what the barber is doing. If the barber is sleeping,
then the customer wakes him up and sits in the chair. If the barber is cutting hair, then the
customer goes to the waiting room. If there is a free chair in the waiting room, the customer sits in
it and waits his turn. If there is no free chair, then the customer leaves.

Based on a naïve analysis, the above description should ensure that the shop functions correctly,
with the barber cutting the hair of anyone who arrives until there are no more customers, and then
sleeping until the next customer arrives. In practice, there are a number of problems that can
occur that are illustrative of general scheduling problems.

You might also like