Talk:Sleeping barber problem

From Wikipedia, the free encyclopedia

This article is part of a WikiProject to improve Wikipedia's articles related to Computer science. For guidelines see WikiProject Computer science and Wikipedia:Contributing FAQ.


Does this page make sense to computer experts? I certainly don't understand it. :-) Jwrosenzweig 00:13, 28 Feb 2004 (UTC)

Not really, I only knew of the dining philosophers problem. This article (and similar pages found by Google) state the rules but not what the difficulty really is - in plain language. I searched and only found homework problems being stated, or programs that claimed to be successful implementations. So why are the locks important? What's the relevance of an unbounded queue? Someone that has actually analysed this needs to write some more text for us!  (-;  – Lee J Haywood 18:46, 15 May 2004 (UTC)
Is it any better now? Dori | Talk 05:37, May 16, 2004 (UTC)
Yes, much better. Personally I'd like to have a clear understanding of what happens when you don't implement a valid solution. For example, with the dining philosophers, it's clear that deadlock occurs when they all take, say, their left forks and then wait for the other – it is then easy to work out the solution for yourself. With this article, the solution is outlined well, but I don't think that it is immediately clear why it is correct to someone who is only vaguely familiar with semaphores. Thanks.  – Lee J Haywood 08:29, 16 May 2004 (UTC)
OK, how about now? :) We'll make an article out of this. Dori | Talk 15:41, May 16, 2004 (UTC)
Okay, I still have 2 points to make. First, the outline of the solution doesn't mention the use of a queue – so starvation would be an issue. Second, the solution says that a new customer can sit in the barber's chair when they arrive, if it is empty, ignoring those in the waiting room. So the solution seems to neglect how the barber actually chooses the next customer and how that customer gets from the waiting room to the chair. Of course, we don't want the whole solution here – it is a homework problem, after all (I'd implement it myself, but I'm very ill at the moment).  – Lee J Haywood 08:23, 17 May 2004 (UTC)
I have to check since it's been a while, but I believe the semaphores take care of the queues. Dori | Talk 15:08, May 17, 2004 (UTC)

I don't get the whole picture - maybe I am not so smart :-}.

In my thinking, each customer enters, take a sit and call the barber to cut his hair. The barber remember who has called him (the "call" will wake him if necessary) and cut the hairs in this order. I fail to see any race conditions here... :-?. Can someone state the prerequisites of this problem more precisely to show what actions are atomic and what not? (As example, how could it be, that the barber wait *on* an customer while this customer wait *on* the barber?)


Since the barber problem is rather illustrative (like the philosophy dinner), maybe replacing the words "semaphore" and "mutex" with illustrative examples could make me understand it?

So if I get it right, a mutex is some kind of a table bell. Each customer enter, sit down and press the bell which will make the bartender awake, right? (Since there is only one bell, they have to wait until the bell is "free").

The semaphore is not as easy for me to map to the barber problem. Currently I just think of the semaphore as the customer chairs, however I fail to see a concurrency problem here (as long as "sit down onto a free chair" is atomic). Maybe it is something different?

--Imi.

Are the semaphore inited to zero? maybe it would be helpfull to show their init in the pseodo code. —The preceding unsigned comment was added by 212.143.92.226 (talkcontribs) .