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

  man pages->IRIX man pages -> usinitsema (3p)              
Title
Content
Arch
Section
 

a(3P)

Contents


USINITSEMA(3P)							USINITSEMA(3P)


NAME    [Toc]    [Back]

     usinitsema	- initialize a semaphore

C SYNOPSIS    [Toc]    [Back]

     #include <ulocks.h>

     int usinitsema (usema_t *sema, int	val);

DESCRIPTION    [Toc]    [Back]

     usinitsema	initializes the	semaphore specified by sema.  The count	of the
     semaphore is set to the value specified by	val. A value of	0 implies no
     available resources, and the first	process	that attempts a	'P' operation
     (via uspsema) will	block.	This can be viewed as a	synchronizing
     semaphore,	since the goal is to always have a process block until another
     has completed an operation	that the first process requires.  Positive
     values for	val can	be used	for tracking a collection of resources.	 The
     simplest case of a	value of 1 implements the common mutual	exclusion
     semaphore,	namely one and only one	process	will be	permitted through a
     semaphore at a time.  Values greater than one imply that up to val
     resources may be simultaneously used, but requests	for more than val
     resources cause the calling process to block until	a resource comes free
     (by a process holding a resource performing a usvsema).

     Metering and debugging are	reinitialized and the history logging
     mechanism is set according	to the global setting (see usconfig(3P)).
     usinitsema	should only be used for	semaphores previously allocated	using
     either usnewsem
.	 Note that usinitsema does not
     check whether any process is currently waiting for	the semaphore.	Any
     such information is lost.	This means that	any processes that are waiting
     for the semaphore (either blocked or queued on a pollable semaphore) will
     not be woken, nor will the	internal counts	kept in	the operating system
     be	reset.

     usinitsema	will fail if the following is true:

     [EINVAL]	    val	must be	greater	than or	equal to 0 and less than
		    30000;

SEE ALSO    [Toc]    [Back]

      
      
     uscpsema(3P), usctlsema(3P), usfreesema(3P), usinit(3P), usnewsema(3P),
     usnewpollsema(3P),	uspsema(3P), usvsema(3P).

DIAGNOSTICS    [Toc]    [Back]

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


									PPPPaaaaggggeeee 1111
[ Back ]
 Similar pages
Name OS Title
usnewsema IRIX allocate and initialize a semaphore
sem_init FreeBSD initialize an unnamed semaphore
sem_init OpenBSD initialize an unnamed semaphore
usnewpollsema IRIX allocate and initialize a pollable semaphore
sem_init IRIX initialize a posix unnamed semaphore
sem_init HP-UX initialize an unnamed POSIX semaphore
msem_init Tru64 Initialize a semaphore in a mapped file or shared memory region
msem_init HP-UX initialize a semaphore in a mapped file or anonymous memory region
semget OpenBSD get semaphore set
sem_getvalue OpenBSD get the value of a semaphore
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service