Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Alexander Terekhov Newsgroups: comp.programming.threads Subject: Re: Comparison of various synchronization mechanisms? Date: Wed, 24 Aug 2011 12:49:30 +0200 Organization: A noiseless patient Spider Lines: 32 Message-ID: <4E54D73A.285BA80B@web.de> References: <0ddf3aed-90df-4cf0-ac3f-7ca6a07ae638@w11g2000vbp.googlegroups.com> <4E4BCB80.6ECB7053@web.de> <4ecbf8fd-1c82-4a9a-a1a0-334df616e5d5@d7g2000vbv.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="16522"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nakB9YnlYGLKIcLMOJc3dljIDimuJMMs=" X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en Cancel-Lock: sha1:O8sjwOx79NwjtXImyqfqjbLA2Ds= Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:524 Papa Stratos wrote: > > > > > What is your real problem regarding (all/one) waiting thread(s), Papa? > > Right now, none really :) I am just trying to educate myself, knowing > which synchronization mechanisms to use when it happens to have > multiple threads waiting on the same lock. Just use a proper type of lock. E.g. it really does make sense for pthread_rwlock_unlock() to unlock multiple blocked readers vs only one blocked writer depending on rwlock's policy (or lack thereof). > > For instance (http://pubs.opengroup.org/onlinepubs/009604499/functions/ > pthread_cond_signal.html), pthread_cond_broadcast() is explicit about > waking all threads. pthread_cond_signal() states "at least one" which > may or may not create performance problems. > > On the Windows side (http://msdn.microsoft.com/en-us/library/ > ms682396%28v=vs.85%29.aspx), signalling an event would wake a single > thread. > > Just curious if I can find a discussion on the subject anywhere. There is plenty of discussion to be found on the net (including archives of this newsgroup) on the topic of pros and cons regarding various types of synchronization objects. Just do a (re)search. regards, alexander.