This is the mail archive of the pthreads-win32@sourceware.cygnus.com mailing list for the pthreads-win32 project. See the pthreads-win32 home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: POSIX4


On Fri, 26 Mar 1999, Michael Ambrus wrote:

> Where can I find a lib implementing POSIX 1003.1b .
> 

Hi,

Courtesy of John Bossom, Pthreads-win32 has an implementation of
semaphores, but those functions aren't exported, just
used internally. This is because they aren't 100% according to the
standard, as the following comments from John's code explains.

 * Module: semaphore.c
 *
 * Purpose:
 *      Semaphores aren't actually part of the PThreads standard.
 *      They are defined by the POSIX Standard:
 *
 *              POSIX 1003.1b-1993      (POSIX.1b)
 *
 *      They are supposed to follow the older UNIX convention for
 *      reporting errors. That is, on failure they are supposed
 *      to return a value of -1 and store the appropriate error
 *      number into 'errno'.
 *      HOWEVER,errno cannot be modified in a multithreaded
 *      program on WIN32; therefore, the value is returned as
 *      the function value.
 *      It is recommended that you compare for zero (0) for success
 *      instead of -1 for failure when checking the status of
 *      these functions.
 *
 * Contents:
 *              Public Methods                    Author
 *              --------------                    ------
 *              sem_init                          John E. Bossom Mar 1998
 *              sem_destroy                       John E. Bossom Mar 1998
 *              sem_trywait                       John E. Bossom Mar 1998
 *              sem_wait                          John E. Bossom Mar 1998
 *              sem_post                          John E. Bossom Mar 1998

You are, of course, free to take this code and build your own
POSIX.1b library.

What is really needed is a thread-safe errno variable, which can be
implemented but it needs to be done in a way that is compatible
across the whole POSIX implementation. I decided to leave that to
others such as the Cygwin project.

Ross

+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+