public inbox for
 help / color / mirror / Atom feed
From: Ross Johnson <>
Subject: Re: Pthread-win32 races?
Date: Wed, 13 Dec 2006 14:26:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Sergey Fokin wrote:
> Hello.
>> The library is working correctly since sem_destroy() is returning the
>> error EBUSY as required and documented at:
>> This is also in accordance with the Single Unix Specification. If it was
>> hanging your program rather than returning the error then that would be
>> a problem.
> The sem_destroy function sets errno to the following error code on error:
> EBUSY if some threads are currently blocked waiting on the semaphore.
> But there's obviously no threads waiting on semaphore, is there?
My apologies - I didn't even see the sem_wait() even though it's right 
before the sem_destroy(), and regardless, as you say, it should only 
return EBUSY if someone is waiting, not posting. It's been a while but 
the code looks like it tries to ensure this. I'll have to look closer 
when I'm more awake.
>> By the way, in your sample code you don't check the return code from the
>> sem_post(), but the semaphore could already be destroyed at that point.
> It couldn't (shouldn't, because actually it does). Because semaphore
> is destroyed only after sem_wait(), but sem_wait() returns (should
> return) only after sem_post() succeeds. Did I understood right?
As above - my mistake.


  reply	other threads:[~2006-12-13 14:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-12 12:27 Sergey Fokin
2006-12-13  8:39 ` Ross Johnson
2006-12-13  9:26   ` Sergey Fokin
2006-12-13 14:26     ` Ross Johnson [this message]
2006-12-20  2:08 ` Ross Johnson
2006-12-12 20:12 Ye Liu

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).