public inbox for
 help / color / mirror / Atom feed
From: Will Bryant <>
Subject: Re: Possible violation of synchronization in pthread_cond_timedwait()
Date: Thu, 18 Nov 2004 03:45:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> wrote:

>I run it in the VC6.0 and found that in CAudioMessageQueue::queuePop() the thread sometimes 
>excuted the "msg = *m_head;" when m_head was equal to NULL! The pthread_cond_timedwait's normal 
>return indicated that the condition waited had been signaled and the queue had at least one 
>message, but there was none in it. 
This is called a 'spurious wakeup'. They happen with all POSIX condition
variables implementations (in fact, all CVs I've ever seen except for
Java's, which prevent them by imposing extra constraints). You need to
loop and re-check your condition (and if necessary wait again) - that's
why they're called condition variables.

See volume 2 of Stevens' "Unix Network Programming", or read the manual
pages for the pthreads CV calls if you can't get a copy of that.

  reply	other threads:[~2004-11-18  3:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-18  3:38 qybupt
2004-11-18  3:45 ` Will Bryant [this message]
2004-11-19 16:26   ` zephyr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).