Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ semctl(2) — DG/UX 4.30

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

ipcrm(1)

ipcs(1)

semget(2)

semop(2)



     semctl(2)                  DG/UX 4.30                   semctl(2)



     NAME
          semctl - Semaphore control operations.

     SYNOPSIS
          #include <sys/types.h>
          #include <sys/ipc.h>
          #include <sys/sem.h>

          int   semctl  (semid, semnum, cmd, arg)
          int             semid;
          int             semnum;
          int             cmd;
          union semun     arg;

     PARAMETERS
          semid          A semaphore set identifier.


          semnum         The subject semaphore. Used only if <cmd> is
                         GETVAL, SETVAL, GETNCNT, GETZCNT or GETPID.


          cmd            The semaphore operation to be performed.


          arg            An argument. Used only if <cmd> is SETVAL,
                         GETALL, SETALL, IPC_STAT, OR IPC_SET.

     DESCRIPTION
          Semctl provides semaphore control operations as specified by
          <cmd>.  The subject semaphore set is identified by <semid>.
          The action taken depends on the value of <cmd> as follows:


          SETVAL
               Set the value of semaphore number <semnum> to
               <arg.val>.

          When this <cmd> is successfully executed, all processes
          having a semaphore adjustment value corresponding to
          semaphore number <semnum> will have those values set to
          zero.

          If an error occurs, the semaphore set is unchanged.


          GETVAL
               Return the value of semaphore number <semnum>.


          GETPID
               Return the process id of the last process to perform an



     Licensed material--property of copyright holder(s)         Page 1





     semctl(2)                  DG/UX 4.30                   semctl(2)



               operation on semaphore number <semnum>.


          GETNCNT
               Return the number of processes waiting for the value of
               semaphore number <semnum> to increase.


          GETZCNT
               Return the number of processes waiting for the value of
               semaphore number <semnum> to become zero.


          SETALL
               Set the value of all semaphores in the specified
               semaphore set to the values contained in the array
               pointed to by <arg.array>.

          When this <cmd> is successfully executed, all processes
          having a semaphore adjustment value corresponding to a
          semaphore in the specified semaphore set will have those
          values set to zero.

          If an error occurs, the semaphore set is unchanged.


          GETALL
               Return the value of all semaphores in the specified
               semaphore set using the array pointed to by
               <arg.array>.

          If an error occurs, the contents of <arg.array> are
          undefined.


          IPC_STAT
               The current semaphore set attributes are stored in the
               structure pointed to by <arg.buf>.

          If an error occurs, the contents of <arg.buf> are undefined.


          IPC_SET
               The following semaphore set attributes are set to the
               values found in the structure pointed to by <arg.buf>:
               user id (sem_perm.uid), group id (sem_perm.gid), and
               permission rights (in sem_perm.mode).

          If an error occurs, the semaphore set remains unchanged.
          Otherwise, the last change time (sem_ctime) is set to the
          current time.




     Licensed material--property of copyright holder(s)         Page 2





     semctl(2)                  DG/UX 4.30                   semctl(2)



          IPC_RMID
               The semaphore set is destroyed.  All resources consumed
               by the semaphore set are freed and the semaphore set
               identifier is invalidated.

          If an error occurs, the semaphore set remains unchanged.

     ACCESS CONTROL
          Operation permission depends on the value of <cmd> as
          follows:

          *    If <cmd> is GETVAL, GETPID, GETNCNT, GETZCNT, GETALL,
               or IPC_STAT, the calling process is required to have
               read access to the semaphore set.

          *    If <cmd> is SETVAL or SETALL, the calling process is
               required to have alter access to the semaphore set.

          *    If <cmd> is IPC_SET or IPC_RMID, the effective user id
               of the calling process must be equal to the semaphore
               set's user id (sem_perm.uid), the semaphore set
               creator's user id (sem_perm.cuid), or that of the
               superuser.

     RETURN VALUE
          The value returned may be the following regardless of the
          value of <cmd>:


          -1             An error occurred.  Errno is set to indicate
                         the error.

          If <cmd> is GETVAL, the value returned may be the following:


          <semaphore_value>
                         Completed successfully.  The specified
                         semaphore's value is returned.

          If <cmd> is GETPID, the value returned may be the following:


          <process_id>   Completed successfully.  The process id of
                         the last process to perform an operation on
                         the specified semaphore is returned.

          If <cmd> is GETNCNT, the value returned may be the
          following:


          <process_id_count>
                         Completed successfully.  The number of



     Licensed material--property of copyright holder(s)         Page 3





     semctl(2)                  DG/UX 4.30                   semctl(2)



                         processes waiting for the value of the
                         specified semaphore to increase is returned.

          If <cmd> is GETZCNT, the value returned may be the
          following:


          <process_id_count>
                         Completed successfully.  The number of
                         processes waiting for the value of the
                         specified semaphore to become zero is
                         returned.

          If <cmd> is SETVAL, GETALL, SETALL, IPC_STAT, IPC_SET, or
          IPC_RMID, the value returned may be the following:


          0              Completed successfully.

     EXCEPTIONS
          Errno may be set to one of the following error codes
          regardless of the value of <cmd>:


          EINVAL         <semid> is not a valid semaphore set
                         identifier.


          EINVAL         <cmd> is invalid.

          If <cmd> is GETVAL, GETPID, GETNCNT, or GETZCNT, errno may
          be set to one of these values:


          EINVAL         <semnum> is less than zero or greater than
                         the number of semaphores in the semaphore set
                         identified by <semid>.


          EACCES         Read permission is denied to the calling
                         process.

          If <cmd> is SETVAL, errno may be set to one of the
          following:


          EINVAL         <Semaphore> is less than zero or greater than
                         the number of semaphores in the semaphore set
                         identified by <semid>.


          EACCES         Alter permission is denied to the calling



     Licensed material--property of copyright holder(s)         Page 4





     semctl(2)                  DG/UX 4.30                   semctl(2)



                         process.


          ERANGE         The value to which the selected semaphore is
                         to be set, <arg.val>, is greater than the
                         system-imposed maximum.

          If <cmd> is GETALL, errno may be set to one of these values:


          EACCES         Read permission is denied to the calling
                         process.


          EFAULT         <Argument.array> points to an illegal
                         address.

          If <cmd> is SETALL, errno may be set to one of these values:


          EACCES         Alter permission is denied to the calling
                         process.


          ERANGE         The value to which one of the semaphores is
                         to be set is greater than the system-imposed
                         maximum.


          EFAULT         <Argument.array> points to an illegal
                         address.

          If <cmd> is IPC_STAT, errno may be set to one of these
          values:


          EACCES         Read permission is denied to the calling
                         process.


          EFAULT         <Argument.buf> points to an illegal address.

          If <cmd> is IPC_SET, errno may be set to one of these
          values:


          EPERM          Permission to change the semaphore set
                         attributes is denied to the calling process.


          EFAULT         <Argument.buf> points to an illegal address.




     Licensed material--property of copyright holder(s)         Page 5





     semctl(2)                  DG/UX 4.30                   semctl(2)



          If <cmd> is IPC_RMID, errno may be set to this value:


          EPERM          Permission to remove the semaphore set is
                         denied to the calling process.

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















































     Licensed material--property of copyright holder(s)         Page 6



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026