Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
semctl(2)		      System Calls Manual		     semctl(2)

NAME
       semctl -	semaphore control operations

SYNOPSIS
DESCRIPTION
       The  system  call provides a variety of semaphore control operations as
       specified by cmd.  The fourth argument is optional and depends  on  the
       operation requested.  If	present, it must be of type which the applica-
       tion program must explicitly declare.  For the meaning  of  unspecified
       variables, see in glossary(9).

       The following values for	cmd are	executed with respect to the semaphore
       specified by semid and semnum:

	      Return the value of
			     semval.  Requires semaphore Read permission.

	      Set the value of
			     semval to arg.val,	where arg is the fourth	 argu-
			     ment  of taken as a When this cmd is successfully
			     executed, the semadj value	corresponding  to  the
			     specified	semaphore in all processes is cleared.
			     Requires semaphore	Alter permission.

	      Return the value of
			     sempid.  Requires semaphore Read permission.

	      Return the value of
			     semncnt.  Requires	semaphore Read permission.

	      Return the value of
			     semzcnt.  Requires	semaphore Read permission.

       The following values for	cmd return and set, respectively, every	semval
       in the set of semaphores.

	      Place	     semvals into array	pointed	to by arg.array, where
			     arg is the	fourth argument	of taken as a Requires
			     semaphore Read permission.

	      Set	     semvals  according	 to  the  array	 pointed to by
			     arg.array,	where arg is the  fourth  argument  of
			     taken  as	a  When	 this cmd is successfully exe-
			     cuted, the	semadj values  corresponding  to  each
			     specified semaphore in all	processes are cleared.
			     Requires semaphore	Alter permission.

       The following values for	cmd are	also available:

	      Place the	current	value of each member
			     of	the data structure associated with semid  into
			     the structure pointed to by arg.buf, where	arg is
			     the fourth	argument of taken as a The contents of
			     this  structure  are defined in glossary(9).  Re-
			     quires semaphore Read permission.

	      Set the value of the following members of	the data structure as-
	      sociated with
			     semid  to	the  corresponding  value found	in the
			     structure pointed to by arg.buf, where arg	is the
			     fourth argument of	taken as a

			     This  cmd	can only be executed by	a process that
			     has an effective user ID equal to either that  of
			     superuser	or  to	the  value of either or	in the
			     data structure associated with semid.

	      Remove the semaphore identifier specified	by
			     semid from	the system and destroy the set of sem-
			     aphores  and  data	 structure associated with it.
			     This cmd can only be executed by a	 process  that
			     has  an effective user ID equal to	either that of
			     superuser or to the value of  either  or  in  the
			     data structure associated with semid.

RETURN VALUE
       Upon successful completion, returns a value based on cmd	as follows:

	      The value	of   semval.
	      The value	of   semncnt.
	      The value	of   semzcnt.
	      The value	of   sempid.

       All others return

       If it fails, it returns and sets	to indicate the	error.

ERRORS
       If fails, it sets to one	of the following values:

	      [EACCES]	     Operation	permission  is	denied	to the calling
			     process (see in glossary(9).

	      [EFAULT]	     cmd is or and arg is an invalid pointer.

	      [EINVAL]	     semid is not a valid semaphore identifier.

	      [EINVAL]	     semnum is less than zero or greater than or equal

	      [EINVAL]	     cmd is not	a valid	command, or the	 command  con-
			     tains invalid parameters.

	      [EPERM]	     cmd  is equal to or and the process does not have
			     an	effective user ID equal	to either that of  su-
			     peruser  or to the	value of either	or in the data
			     structure associated with semid.

	      [ERANGE]	     cmd is or and the value to	which semval is	to  be
			     set is greater than the system imposed maximum.

EXAMPLES
       The following call to initializes the set of 4 semaphores to the	values
       0, 1, 0,	and 1 respectively.  This example assumes the  process	has  a
       valid  semid  representing  a  set  of  4  semaphores  as  shown	in the
       semget(2) manual	entry.	For an example of performing "P" and "V" oper-
       ations on the semaphores	below, refer to	semop(2).

SEE ALSO
       ipcrm(1), ipcs(1), semget(2), semop(2), glossary(9).

STANDARDS CONFORMANCE
								     semctl(2)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | EXAMPLES | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=semctl&sektion=2&manpath=HP-UX+11.22>

home | help