delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/18/02:57:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
content-class: urn:content-classes:message
Subject: RE: pthread_cond_wait does not relock mutex on release
MIME-Version: 1.0
Date: Thu, 18 Apr 2002 16:57:13 +1000
X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3
Message-ID: <FC169E059D1A0442A04C40F86D9BA7600C5E5C@itdomain003.itdomain.net.au>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
To: "Michael Labhard" <ince AT pacifier DOT com>, <cygwin AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g3I6vYE16857


> -----Original Message-----
> From: Michael Labhard [mailto:ince AT pacifier DOT com] 
> Sent: Wednesday, April 17, 2002 10:51 PM
> To: cygwin AT cygwin DOT com
> Subject: Re: pthread_cond_wait does not relock mutex on release
> 
> 
> Robert and Gerald:
> 
>          Both quite right.  Although adding the SAFE_PRINTF made no 
> difference in the 
> output, checking a condition value in a loop made all the 
> difference.  
> Putting a printf in the loop revealed to my surprise that 
> "spurious wakeups" 
> were occurring thousands of times per second.  I had naively 
> assumed that a 
> condition would stay set until signalled.  Now I'm led to wonder if a 
> condition variable is any performance improvement over a 
> simple loop and 
> short sleep.  Any thoughts?

Without knowing what you are trying to achieve, I can't comment. However: in multi-threaded programs, a condition variable will almost invariably be more efficient than a loop + sleep.

As for conditions staying set, that isn't the purpose of condition variables: they are designed to allow signalling between threads, to allow efficient use of cpu resources - and to avoid that loop+sleep approach.

Rob

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019