Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Alexander Terekhov Newsgroups: comp.programming.threads Subject: Re: cond signal wait Date: Sat, 28 May 2011 15:48:16 +0200 Organization: A noiseless patient Spider Lines: 20 Message-ID: <4DE0FD20.8FA7464A@web.de> References: <87aaebte7o.fsf@justsoftwaresolutions.co.uk> <98cd47de-73d9-48e9-ac18-cc01cac1bb48@z7g2000prh.googlegroups.com> <87lixubzfu.fsf@justsoftwaresolutions.co.uk> <8ab4e07e-2b9b-4375-b425-dc03e6d017d5@f15g2000pro.googlegroups.com> Reply-To: terekhov@web.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="MCbSEzW5qwGLFMNXJh39IQ"; logging-data="11905"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t8xNrC254NHYyq6MH14vTrIC0Jz35mRQ=" X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en Cancel-Lock: sha1:COVCWQpQr5dRDWriBmiMDtcnuW8= Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:203 David Schwartz wrote: [... "if" v. "while" ...] > It's the same point. If the condition variable code had access to the > predicate, it could make a sensible decision of whether to repeat the > wait or not. But since the condition variable implementation has no > access to the predicate, the only sensible way to handle a case where > there might have been a signal is to return. AFAIK, when Hoare invented condition variables he saw only signal (no broadcast) operation and "if" (not "while") for the wait with signalling done under protection of mutex (hand-off of mutex ownership from signaller to signallee akin to semas). Later, MESA folks introduced broadcast, changed "if" to "while", and allowed signalling without holding mutex. regards, alexander.