From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27194 invoked by alias); 9 Sep 2004 09:11:33 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 27187 invoked from network); 9 Sep 2004 09:11:32 -0000 Received: from unknown (HELO callisto.canberra.edu.au) (137.92.14.50) by sourceware.org with SMTP; 9 Sep 2004 09:11:32 -0000 Received: from ise.canberra.edu.au (nyx.canberra.edu.au [137.92.14.55]) by callisto.canberra.edu.au (8.11.6/8.11.6) with ESMTP id i899BTo20022 for ; Thu, 9 Sep 2004 19:11:30 +1000 Message-ID: <41401E36.5060501@ise.canberra.edu.au> Date: Thu, 09 Sep 2004 09:11:00 -0000 From: Ross Johnson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 MIME-Version: 1.0 To: pthreads-win32@sources.redhat.com Subject: Re: FW: sem_getvalue() References: <31173C0B4EF5D611A021009027CB2CBD04EE2CC6@fl08exm04> In-Reply-To: <31173C0B4EF5D611A021009027CB2CBD04EE2CC6@fl08exm04> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004/txt/msg00110.txt.bz2 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 > > >