21-Classical+Synchronization+Problems-SB

21-Classical+Synchronization+Problems-SB - (when all the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sleeping Barber Problem Mehreen Alam
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
April 15, 2009 Operating Systems - Mehreen Alam Sleeping Barber Problem There is one barber, and n chairs for waiting customers If there are no customers, then the barber sits in his chair and sleeps (as illustrated in the picture) When a new customer arrives and the barber is sleeping, then he will wakeup the barber When a new customer arrives, and the barber is busy, then he will sit on the chairs if there is any available, otherwise
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (when all the chairs are full) he will leave. April 15, 2009 Operating Systems - Mehreen Alam Barber Shop Hints Consider the following: Customer threads should invoke a function named getHairCut. If a customer thread arrives when the shop is full, it can invoke balk, which exits. Barber threads should invoke cutHair. When the barber invokes cutHair there should be exactly one thread invoking getHairCut concurrently....
View Full Document

Page1 / 3

21-Classical+Synchronization+Problems-SB - (when all the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online