sem_open

What are the parameters after the oflags of sem_open( const char * sem_name,
int oflags, … )
I want to specify a starting value of 1. I look at some reference but they
don’t tell all the same thing.
Is it sem_open( const char * sem_name, int oflags, int mode , int starting
value )?
Thanks,

Rejean Senecal <rsenecal@oerlikon.ca-no-spam> wrote:

: What are the parameters after the oflags of sem_open( const char * sem_name,
: int oflags, … )
: I want to specify a starting value of 1. I look at some reference but they
: don’t tell all the same thing.
: Is it sem_open( const char * sem_name, int oflags, int mode , int starting
: value )?

I’ve been working on the Library Reference to make sure that all of the
arguments are described. Here’s what the latest (unreleased) version of the
docs says:

If you set O_CREAT in oflags, you must also pass the following
arguments:

mode_t mode
The semaphore’s mode (just like file modes). For portability, you
should set the read, write, and execute bits to the same value. An
easy way of doing this is to use the constants from
<sys/stat.h>:

S_IRWXG for group access.
S_IRWXO for other’s access.
S_IRWXU for your own access.

For more information, see “Access permissions” in the documentation for
stat().

unsigned int value
The initial value of the semaphore. A positive value (i.e. greater than
zero) indicates an unlocked semaphore, and a value of 0 (zero)
indicates a locked semaphore. This value must not exceed
SEM_VALUE_MAX.


I hope this helps.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems