On Wed, 18 Sep 2002, Terry Lambert wrote: > Alfred Perlstein wrote: > > Ok, any of you guys have a copy of the standards documents that > > describe the sem_* API? > > > > I have a question... > > > > What are the semantics of the sem_init when pshared is set to true? > > The sem_init() function is used to initialise the unnamed > semaphore referred to by sem. The value of the initialised > semaphore is value. Following a successful call to sem_init(), > the semaphore may be used in subsequent calls to sem_wait(), > sem_trywait(), sem_post(), and sem_destroy(). This semaphore > remains usable until the semaphore is destroyed. > > If the pshared argument has a non-zero value, then the > semaphore is shared between processes; in this case, any > process that can access the semaphore sem can use sem for > performing sem_wait(), sem_trywait(), sem_post(), and > sem_destroy() operations. > > Only sem itself may be used for performing synchronisation. > The result of referring to copies of sem in calls to > sem_wait(), sem_trywait(), sem_post(), and sem_destroy(), is > undefined. > > If the pshared argument is zero, then the semaphore is shared > between threads of the process; any thread in this process can > use sem for performing sem_wait(), sem_trywait(), sem_post(), > and sem_destroy() operations. The use of the semaphore by > threads other than those created in the same process is > undefined. > > Attempting to initialise an already initialised semaphore > results in undefined behaviour. > > > Like, if the process that created the semaphore exits, then what? > > The use of the semaphore by threads other than those created > in the same process is undefined.
Terry, your forgot to prefix that with "If the pshared argument is zero". Alfred's concerned with pshared != 0. > > Is it only valid for the life of the process that did the sem_init? > > The use of the semaphore by threads other than those created > in the same process is undefined. Same here. -- Dan Eischen To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message