public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Ross Johnson <rpj@ise.canberra.edu.au>
To: pthreads-win32@sources.redhat.com
Subject: Re: FW: sem_getvalue()
Date: Thu, 09 Sep 2004 09:11:00 -0000	[thread overview]
Message-ID: <41401E36.5060501@ise.canberra.edu.au> (raw)
In-Reply-To: <31173C0B4EF5D611A021009027CB2CBD04EE2CC6@fl08exm04>

The pthreads-win32 implementation never returns a negative 
number, only zero or a positive number (i.e. the actual 
semaphore value as close as can be determined). I read it as 
optional because it could easily be written unambiguously. 
However, it would be worth asking the austin group list for 
a clarification.

Ross

Blanco Alejandro-EAB005 wrote:

>I experienced an unusual return value from sem_getValue(), and traced it back to the actual POSIX spec that is troubling.  I had thought this would return a value < 0 if there are threads waiting on the semaphore, where the absolute value is the number of threads waiting.  I saw that it was returning 0 when I had a thread waiting.  I looked up the spec (http://www.opengroup.org/onlinepubs/009695399/functions/sem_getvalue.html), and it says:
>
>  
>
>>The sem_getvalue() function shall update the location referenced by the sval argument to have the value of the semaphore referenced by sem without affecting the state of the semaphore. The updated value represents an actual semaphore value that occurred at some unspecified time during the call, but it need not be the actual value of the semaphore when it is returned to the calling process.
>>    
>>
>
>If sem is locked, then the object to which sval points shall either be set to zero **or** to a negative number whose absolute value represents the number of processes waiting for the semaphore at some unspecified time during the call.
>
>Is it really optional to return the negative number?  Does the implementation, at least sometimes, return 0 only?
>
>Alex Blanco
>
>  
>

  parent reply	other threads:[~2004-09-09  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-08 18:59 Blanco Alejandro-EAB005
2004-09-08 19:59 ` Alexander Terekhov
2004-09-09  9:11 ` Ross Johnson [this message]
2004-09-08 20:17 Blanco Alejandro-EAB005
2004-09-08 20:34 ` Alexander Terekhov
2004-09-09 12:59 Blanco Alejandro-EAB005
2004-09-09 13:55 ` Alexander Terekhov
2004-09-09 14:12 Blanco Alejandro-EAB005
2004-09-09 14:26 ` Alexander Terekhov

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=41401E36.5060501@ise.canberra.edu.au \
    --to=rpj@ise.canberra.edu.au \
    --cc=pthreads-win32@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

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