From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23981 invoked by alias); 30 May 2002 14:49:37 -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 23972 invoked from network); 30 May 2002 14:49:35 -0000 Received: from unknown (HELO sotr0085.cognos.com) (205.210.232.62) by sources.redhat.com with SMTP; 30 May 2002 14:49:35 -0000 Received: by sotr0085.cognos.com with Internet Mail Service (5.5.2653.19) id ; Thu, 30 May 2002 10:48:54 -0400 Message-ID: <430F887D415DD1118C2700805F31ECF106B591B1@sota0005.cognos.com> From: "Bossom, John" To: 'Rob Fanner' , pthreads-win32@sources.redhat.com Subject: RE: semaphores Date: Thu, 30 May 2002 07:49:00 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C207E9.1D225980" X-SW-Source: 2002/txt/msg00065.txt.bz2 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C207E9.1D225980 Content-Type: text/plain; charset="iso-8859-1" Content-length: 2295 sem_getvalue()? I don't see that in the standard (POSIX.1b (POSIX 1003.1b-1993))... I assume this has been added to the pthreads-win32 implementation as an extension (Ross?) Perhaps there is a bug in that new method. However, try looping over sem_trywait and count the # of times it returns 0. It should return EAGAIN when the semaphore count is zero. Sorry, I can't help you with the sem_getvalue.... Note that since the sem_ calls are from an earlier standard, that when they fail they are supposed to return -1 and set errno to the actual error number.... John. -----Original Message----- From: Rob Fanner [mailto:rfanner@stonethree.com] Sent: May 30, 2002 10:10 AM To: pthreads-win32@sources.redhat.com Subject: semaphores I'm new to using pthreads-win32 (SNAPSHOT 2002-03-02), and I have to port a program from Linux to Windows 2000. A bug has somehow crept into my code, and I've narrowed the problem area down to a code fragment similar to the following: #include #include #include using namespace std; int main() { /** * We want to check wether a semaphore can be initialised * with a value. */ // a semaphore sem_t psem; // initialise it with value 10 assert(sem_init(&psem,0,10) == 0); // ASSERT NO 1 // if the semaphore initialisation was ok, the sem // should now have the value 10 int ret = 0; assert(sem_getvalue(&psem,&ret) == 0); // ASSERT NO 2 // if no errors occured then value is now in the // integer ret cout << endl << "sem_getvalue() returns value " << ret << endl << flush; return 0; } I'm using MS VC++ 6.0, and I'm linking with the precompiled pthreadVCE.lib library. At runtime, the first assert() passes OK, but second fails. I have no idea why this fails (hopefully it's simply a newby error, and not a bug in the pthreads-win32 lib), but it does. Thanks Rob This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you. ------_=_NextPart_001_01C207E9.1D225980 Content-Type: text/html; charset="iso-8859-1" Content-length: 5750
sem_getvalue()?
 
I don't see that in the standard (POSIX.1b (POSIX 1003.1b-1993))... I assume this
has been added to the pthreads-win32 implementation as an extension (Ross?)
 
Perhaps there is a bug in that new method.
 
However, try looping over sem_trywait and count the # of times it returns 0. It should return EAGAIN
when the semaphore count is zero.
 
Sorry, I can't help you with the sem_getvalue....
 
Note that since the sem_ calls are from an earlier standard, that when they fail they are supposed
to return -1 and set errno to the actual error number....
 
John.
-----Original Message-----
From: Rob Fanner [mailto:rfanner@stonethree.com]
Sent: May 30, 2002 10:10 AM
To: pthreads-win32@sources.redhat.com
Subject: semaphores

I'm new to using pthreads-win32 (SNAPSHOT 2002-03-02), and I have to port 
a program from Linux to Windows 2000. A bug has somehow crept into my
code, and I've narrowed the problem area down to a code fragment similar
to the following:
 
#include <semaphore.h>
#include <cassert>
#include <iostream>
 
using namespace std;
 
int main()
{
   /**
    * We want to check wether a semaphore can be initialised
    * with a value.
    */
  
   // a semaphore
   sem_t psem;
 
   // initialise it with value 10
   assert(sem_init(&psem,0,10) == 0);                       // ASSERT NO 1
   // if the semaphore initialisation was ok, the sem
   // should now have the value 10
   int ret = 0;
   assert(sem_getvalue(&psem,&ret) == 0);               // ASSERT NO 2
   // if no errors occured then value is now in the
   // integer ret
   cout << endl << "sem_getvalue() returns value " << ret << endl << flush;
 
   return 0;
}
 
I'm using MS VC++ 6.0, and I'm linking with the precompiled pthreadVCE.lib library.
At runtime, the first assert() passes OK, but second fails.
I have no idea why this fails (hopefully it's simply a newby error, and not a bug in
the pthreads-win32 lib), but it does.
 
Thanks
Rob

This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.

------_=_NextPart_001_01C207E9.1D225980--