From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31372 invoked by alias); 30 May 2002 14:11:39 -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 31364 invoked from network); 30 May 2002 14:11:35 -0000 Received: from unknown (HELO mail.twc-online.net) (66.8.86.35) by sources.redhat.com with SMTP; 30 May 2002 14:11:35 -0000 Received: from mondriaan.stonethree.com (cache-1.twc-online.net [66.8.86.58]) by mail.twc-online.net (8.11.3/8.11.3) with ESMTP id g4UEBXR25402 for ; Thu, 30 May 2002 16:11:34 +0200 Received: from thor (thor.stonethree.com [192.168.1.12]) by mondriaan.stonethree.com (8.11.0/8.11.0) with SMTP id g4UEBP301522 for ; Thu, 30 May 2002 16:11:27 +0200 Message-ID: <00c301c207e3$bb64ef00$0c01a8c0@thor> From: "Rob Fanner" To: Subject: semaphores Date: Thu, 30 May 2002 07:11:00 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00C0_01C207F4.7E31C200" X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-SW-Source: 2002/txt/msg00064.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_00C0_01C207F4.7E31C200 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 1234 I'm new to using pthreads-win32 (SNAPSHOT 2002-03-02), and I have to port=20 a program from Linux to Windows 2000. A bug has somehow crept into my=20 code, and I've narrowed the problem area down to a code fragment similar=20 to the following: #include #include #include using namespace std; int main() { /** * We want to check wether a semaphore can be initialised * with a value. */ =20=20=20 // a semaphore sem_t psem; // initialise it with value 10 assert(sem_init(&psem,0,10) =3D=3D 0); // ASSERT N= O 1 // if the semaphore initialisation was ok, the sem // should now have the value 10 int ret =3D 0; assert(sem_getvalue(&psem,&ret) =3D=3D 0); // ASSERT NO 2 // if no errors occured then value is now in the=20 // integer ret cout << endl << "sem_getvalue() returns value " << ret << endl << flush; =20 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=20 the pthreads-win32 lib), but it does. Thanks Rob ------=_NextPart_000_00C0_01C207F4.7E31C200 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 2919
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 d= own to a=20 code fragment similar
to the following:
 
#include <semaphore.h>
#include=20 <cassert>
#include <iostream>
 
using namespace std;
 
int main()
{
  =20 /**
    * We want to check wether a semaphore can be=20 initialised
    * with a value.
   =20 */
  
   // a semaphore
   sem_t=20 psem;
 
   // initialise it with value=20 10
   assert(sem_init(&psem,0,10) =3D=3D=20 0);            =           =20 // ASSERT NO 1
   // if the semaphore initialisation was ok, t= he=20 sem
   // should now have the value 10
   int ret= =3D=20 0;
   assert(sem_getvalue(&psem,&ret) =3D=3D=20 0);            =   =20 // ASSERT NO 2
   // if no errors occured then value is now in= the=20
   // integer ret
   cout << endl <<= =20 "sem_getvalue() returns value " << ret << endl <<=20 flush;
 
   return 0;
}
 
I'm using MS VC++ 6.0, and = I'm=20 linking with the precompiled pthreadVCE.lib library.
At runtime, the first assert() passes OK, = but=20 second fails.
I have no idea why this fails (hopefully i= t's=20 simply a newby error, and not a bug in
the pthreads-win32 lib), but it does.
 
Thanks
Rob
------=_NextPart_000_00C0_01C207F4.7E31C200--