Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ semop(2) — DG/UX 5.4R2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ipcrm(1)

ipcs(1)

intro(2)

exec(2)

exit(2)

fork(2)

semctl(2)

semget(2)



semop(2)                     DG/UX 5.4 Rel. 2.01                    semop(2)


NAME
       semop - semaphore operations

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

       int      semop (semid, sops, nsops)
       int      semid;
       struct sembuf * sops;
       unsigned nsops;

   where:
       semid     A semaphore set identifier

       sops      An array of semaphore operations to perform

       nsops     The number of semaphore operation records in sops

DESCRIPTION
       Semop atomically performs nsops semaphore operations on the semaphore
       set identified by semid.  The semaphore operation records are located
       in the array given by sops.

       A semaphore operation has three components: a semaphore number
       (semnum), a semaphore operation (semop), and an operation modifier
       (semflg).  A semaphore operation is performed by applying the
       operation, semop, modified by semflg, to the semaphore specified by
       semnum in the semaphore set identified by semid.  Semop specifies
       one of three semaphore operations as follows:

       ⊕      semop < 0:  Perform a P operation

       If the semaphore's value is greater than or equal to the absolute
       value of semop, the operation is successful.  In this case, the
       absolute value of semop is subtracted from the semaphore's value,
       and, if the SEM_UNDO bit of semflg is set, the absolute value of
       semop is added to the calling process's semaphore adjustment value
       for the semaphore.

       If the semaphore's value is less than the absolute value of semop
       and the IPC_NOWAIT bit of semflg is set, semop will return with the
       error condition EAGAIN.

       If the semaphore's value is less than the absolute value of semop
       and the IPC_NOWAIT bit of semflg is clear, semop will suspend the
       calling process until:

              ⊕      the semaphore's value becomes greater than or equal to
                     the absolute value of semop, in which case, the
                     operation is retried,

              ⊕      semid is removed from the system, in which case, semop



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




semop(2)                     DG/UX 5.4 Rel. 2.01                    semop(2)


                     will return with the error condition EIDRM, or

              ⊕      the calling process receives a signal that is to be
                     caught, in which case, semop will return with the error
                     condition EINTR.

       ⊕      semop > 0:  Perform a V operation

       The value of semop is added to the semaphore's value and, if the
       SEM_UNDO bit of semflg is set, the value of semop is subtracted
       from the calling process's semaphore adjustment value for the
       semaphore.

       ⊕      semop == 0:  Wait for zero

       If the semaphore's value is zero, the operation is successful.

       If the semaphore's value is non-zero and the IPC_NOWAIT bit of semflg
       is set, semop will return with the error condition EAGAIN.

       If the semaphore's value is non-zero and the IPC_NOWAIT bit of
       semflg is clear, semop will suspend the calling process until:

              ⊕      the semaphore's value becomes zero or equal to the
                     absolute value of semop, in which case, the operation
                     is retried,

              ⊕      semid is removed from the system, in which case, semop
                     will return with the error condition EIDRM, or

              ⊕      the calling process receives a signal that is to be
                     caught, in which case, semop will return with the error
                     condition EINTR.

       The operation performed by semop is the composition of the individual
       operations given by sops.  This composition is subject to the
       following:

       ⊕      Semop performs the composite operation atomically.  Semop
              succeeds and changes all subject semaphores only when all
              individual operations can be performed at a given time.

       ⊕      The calling process is suspended due to the first individual
              operation in sops that requires suspension.

       ⊕      When the calling process is suspended, it is registered as
              waiting for only one semaphore's value to either increase or
              become zero, that semaphore being the subject semaphore of the
              individual operation that suspended the process.

       ⊕      Neither the individual operations nor the composite operation
              are guaranteed to solve the mutual exclusion livelock problem.

       If semop fails, the semaphore set will remain unchanged.  Upon



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




semop(2)                     DG/UX 5.4 Rel. 2.01                    semop(2)


       successful completion, the calling process is recorded as the last
       process to perform an operation on each semaphore specified in the
       array pointed to by sops and the current time is recorded as the most
       recent time a semop operation was performed.

ACCESS CONTROL
       Alter access to the semaphore set is required to change the value of
       a semaphore.  Read access is required to wait for a semaphore value
       to become zero.

RETURN VALUE
       0      Completed successfully.

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

DIAGNOSTICS
       Errno may be set to one of the following error codes:

       EINVAL    Semid is not a valid semaphore set identifier.

       EINVAL    The number of semaphore sets for which the calling process
                 requests a SEM_UNDO would exceed the system-imposed limit.

       EFBIG     Semnum is less than zero or greater than or equal to the
                 number of semaphores in the set associated with semid for
                 one or more semaphore operations.

       E2BIG     nsops is greater than the system-imposed maximum.

       EACCES    One of the semaphore operations (semop) is non-zero and
                 the caller does not have write access.

       EACCES    One of the semaphore operations (semop) is zero and the
                 caller does not have read access.

       EFAULT    sops is an illegal address.

       EAGAIN    Semaphore operations would result in suspension of the
                 caller who has requested IPC_NOWAIT

       ENOSPC    The limit on the number of processes requesting a SEM_UNDO
                 would be exceeded.

       ERANGE    One of the semaphore operations would cause a semaphore's
                 value to overflow the system-imposed limit.

       ERANGE    One of the semaphore operations would cause a process's
                 semaphore adjustment value to overflow the system-imposed
                 limit.

       EIDRM     semid was removed from the system while the caller was
                 suspended by semop.

       EINTR     The caller received a signal that was set to be caught



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




semop(2)                     DG/UX 5.4 Rel. 2.01                    semop(2)


                 while suspended by semop.

SEE ALSO
       ipcrm(1), ipcs(1), intro(2), exec(2), exit(2), fork(2), semctl(2),
       semget(2).




















































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


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