Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Message-ID: <012601c0ece3$120f5560$0200a8c0@lifelesswks> From: "Robert Collins" To: "Jeff Waller" , , References: <3B1B504C DOT 8090808 AT 141monkeys DOT org> <010201c0ecda$526e7450$0200a8c0 AT lifelesswks> Subject: Re: pthread_cond_timedwait, etc Date: Mon, 4 Jun 2001 20:42:31 +1000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0123_01C0ED36.E0A6F970" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-OriginalArrivalTime: 04 Jun 2001 10:33:47.0939 (UTC) FILETIME=[D6A63F30:01C0ECE1] This is a multi-part message in MIME format. ------=_NextPart_000_0123_01C0ED36.E0A6F970 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit ----- Original Message ----- From: "Robert Collins" > this may be an artifact of a particularly horrendous patch I had to > generate at one point. That does look buggy to me. Patch coming shortly. Patch attached at the end of the email. Thanks for catching that. pthread_cond_wait was also bust. > We could ignore it and return.. I'll try and get time to > check the spec and see if that's the expected behaviour. If it is, > consider that error a useful diagnostic for your code :]. pthread_cond_broadcast is meant to never have an error, except when the condvariable is invalid. The attached patch fixs that little bit of bitrot as well. It snuck in from my test _verbose_ test code, and should have been trimmed back a little :]. You probably have code calling pthread_cond_broadcast to ensure that no threads are waiting when you exit the program. Changelog Mon Jun 4 20:39:00 2001 Robert Collins * thread.cc (pthread_cond::Broadcast): Don't print error messages on invalid mutexs - user programs are allowed to call pthread_cond_broadcast like that. __pthread_cond_timedwait: Initialise themutex properly. __pthread_cond_wait: Initialise themutex properly. Rob ------=_NextPart_000_0123_01C0ED36.E0A6F970 Content-Type: application/octet-stream; name="pthread_cond_broadcast_fix.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pthread_cond_broadcast_fix.patch" Index: thread.cc=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v=0A= retrieving revision 1.32=0A= diff -u -p -r1.32 thread.cc=0A= --- thread.cc 2001/05/06 22:23:43 1.32=0A= +++ thread.cc 2001/06/04 10:34:58=0A= @@ -424,7 +424,10 @@ pthread_cond::BroadCast ()=0A= {=0A= if (pthread_mutex_unlock (&cond_access))=0A= system_printf ("Failed to unlock condition variable access = mutex, this %0p\n", this);=0A= - system_printf ("Broadcast called with invalid mutex\n");=0A= + /* This isn't and API error - users are allowed to call this when = no threads =0A= + are waiting =0A= + system_printf ("Broadcast called with invalid mutex\n");=0A= + */=0A= return;=0A= }=0A= while (count--)=0A= @@ -1639,6 +1642,8 @@ __pthread_cond_timedwait (pthread_cond_t=0A= if ((((pshared_mutex *)(mutex))->flags & SYS_BASE =3D=3D SYS_BASE))=0A= // a pshared mutex=0A= themutex =3D __pthread_mutex_getpshared (mutex);=0A= + else=0A= + themutex =3D mutex;=0A= =0A= if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))=0A= return EINVAL;=0A= @@ -1685,6 +1690,8 @@ __pthread_cond_wait (pthread_cond_t * co=0A= if ((((pshared_mutex *)(mutex))->flags & SYS_BASE =3D=3D SYS_BASE))=0A= // a pshared mutex=0A= themutex =3D __pthread_mutex_getpshared (mutex);=0A= + else=0A= + themutex =3D mutex;=0A= if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))=0A= return EINVAL;=0A= if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))=0A= ------=_NextPart_000_0123_01C0ED36.E0A6F970--