*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> sem_wait (3c)              


sem_wait(3C)							  sem_wait(3C)

NAME    [Toc]    [Back]

     sem_wait, sem_trywait - acquire a posix named or unnamed semaphore

SYNOPSIS    [Toc]    [Back]

     #include <semaphore.h>

     int sem_wait(sem_t	*sem<b>);
     int sem_trywait(sem_t *sem<b>);

DESCRIPTION    [Toc]    [Back]

     sem_wait atomically decrements the	value of the semaphore located at
     address sem.  If the semaphore's value is less than zero after the
     decrement,	the calling process blocks on the semaphore.  Otherwise, the
     calling process continues without blocking.

     A process blocked on a semaphore remains blocked until either another
     process posts the semaphore via sem_post, or the sem_wait operation is
     interrupted by a signal.

     sem_trywait atomically decrements the semaphore only if the resulting
     value is greater than or equal to zero.  This way,	the sem_trywait
     function will never cause the calling process to block on the semaphore.

     The address sem may reside	anywhere in the	calling	processes address
     space, but	the process must have read and write access to sem.

     sem_wait or sem_trywait will fail if one or more of the following are

     [EAGAIN]	 sem_trywait will generate this	error if the semaphore was not

     [EDEADLK]	 A deadlock condition was detected.

     [EINVAL]	 The semaphore located at address sem is not a valid posix
		 named or unnamed semaphore.

     [EINTR]	 The operation was interrupted by a signal.

SEE ALSO    [Toc]    [Back]

     sem_init(3C), sem_destroy(3C), sem_getvalue(3C), sem_post(3C),
     sem_wait(3C), sem_trywait(3C), sem_open(3C), sem_close(3C),

DIAGNOSTICS    [Toc]    [Back]

     Upon successful completion, a value of 0 is returned to the calling
     process. Otherwise, a value of -1 is returned and errno is	set to
     indicate the error.

									PPPPaaaaggggeeee 1111
[ Back ]
 Similar pages
Name OS Title
sem_getvalue IRIX get the value of a posix named or unnamed semaphore
sem_post IRIX release a posix named or unnamed semaphore
sem_destroy IRIX deinitialize a posix unnamed semaphore
sem_destroy HP-UX destroy an unnamed POSIX semaphore
sem_init HP-UX initialize an unnamed POSIX semaphore
sem_init IRIX initialize a posix unnamed semaphore
sem_mode IRIX set the operation mode of a POSIX unnamed semaphore
pipcrm HP-UX remove a POSIX message queue or a POSIX named semaphore
sem_close IRIX close a posix named semaphore
sem_open IRIX open a posix named semaphore
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service