From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12937 invoked by alias); 26 Feb 2002 17:41:34 -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 12823 invoked from network); 26 Feb 2002 17:41:30 -0000 Received: from unknown (HELO smtpzilla5.xs4all.nl) (194.109.127.141) by sources.redhat.com with SMTP; 26 Feb 2002 17:41:30 -0000 Received: from PATRICK_DESKTOP (s340-modem3173.dial.xs4all.nl [194.109.172.101]) by smtpzilla5.xs4all.nl (8.12.0/8.12.0) with SMTP id g1QHfSnI062334 for ; Tue, 26 Feb 2002 18:41:29 +0100 (CET) From: Patrick Frants To: pthreads-win32@sourceware.cygnus.com Date: Tue, 26 Feb 2002 09:41:00 -0000 X-Priority: 3 (Normal) Organization: Quintiq BV Message-Id: Subject: sem_trywait never returns EAGAIN MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Mailer: Opera 6.01 build 1041 X-SW-Source: 2002/txt/msg00028.txt.bz2 Hi, >From the Linux man pages I concluded that calling sem_trywait on a semaphore with a zero count should result in an EAGAIN return value. I get a -1 all time time. Intiializing the count with 1 and calling sem_trywait two times results in 0 and -1 return codes. Initializing with 0, calling sem_trywait results in a -1 return code. Initializing with 0, calling sem_post, and sem_trywait twice results in 0 and -1 return codes for the sem_trywait calls. Are my expectations wrong or is the behaviour of the library wrong? Here is my sample code: #include #include #include #include #pragma comment(lib, "pthreadvce") int main(int argc, char** argv) { sem_t s; assert(sem_init(&s, 0, 0) == 0); int result = sem_trywait(&s); if ( result == -1 ) { perror("sem_wait"); // No error } else { printf("ok\n"); } result = sem_post(&s); result = sem_trywait(&s); if ( result == -1 ) { perror("sem_wait"); } else { printf("ok\n"); } return 0; } -- Patrick Frants Senior Software Engineer Quintiq patrick@quintiq.com www.quintiq.com