Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ semop(PCI) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dflthost(PCI)

Intro(PCI)

semctl(PCI)

semget(PCI)


 semop(PCI)                     6 January 1993                     semop(PCI)


 Name

    semop - semaphore operations

 Syntax


    #include <pcilib.h>


    #include <memmdl.h>


    #include <ipc.h>

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


 Description

    semop is used to perform an array of semaphore operations on the set of
    semaphores associated with the semaphore identifier specified by semid.
    The operations are performed on the current host (as specified in the
    most recent dflthost call).  sops is a pointer to the array of
    semaphore-operation structures.  nsops is the number of such structures
    in the array.  Each structure includes the following members:

       short        sem_num;        /* semaphore number */
       short        sem_op;         /* semaphore operation */
       short        sem_flg;        /* operation flags */

    Each semaphore operation specified by semop is performed on the corre-
    sponding semaphore specified by semid and semnum.

    semop specifies one of three semaphore operations as follows:

    1.  If semop is a negative integer, one of the following occurs:

    If semval (see Intro(PCI)) is greater than or equal to the absolute value
    of semop, the absolute value of semop is subtracted from semval.  Also,
    if (semflg & SEMUNDO) is "true," the absolute value of semop is added
    to the calling process's semadj value for the specified semaphore.  (See
    exit(S) for more information.)

    If semval is less than the absolute value of semop and  (semflg &
    IPCNOWAIT) is "true," semop returns immediately.

    If semval is less than the absolute value of semop and (semflg &
    IPCNOWAIT) is "false," semop returns -1 and errno is set to EIDRM.

    2.  If semop is a positive integer, the value of semop is added to sem-
        val, and if (semflg & SEMUNDO) is "true," the value of semop is
        subtracted from the calling process's semadj value for the specified
        semaphore.

    3.  If semop is zero, one of the following occurs:

    If semval is zero, semop returns immediately.

    If semval is not equal to zero and (semflg & IPCNOWAIT) is "true,"
    semop returns immediately.

    If semval is not equal to zero and (semflg & IPCNOWAIT) is "false,"
    semop returns -1 and errno is set to EIDRM.

    semop fails if one or more of the following are true for any of the sema-
    phore operations specified by sops:

    [EINVAL]  semid is not a valid semaphore identifier.

    [EFBIG]   semnum is less than zero or greater than or equal to the num-
              ber of semaphores in the set associated with semid.

    [E2BIG]   nsops is greater than the UNIX operating system-imposed max-
              imum.

    [EACCES]  Operation permission is denied to the calling process; see
              Intro(PCI).

    [EAGAIN]  The operation would result in suspension of the calling pro-
              cess, but (semflg & IPCNOWAIT) is "true."

    [ENOSPC]  The UNIX operating system limit on the number of individual
              processes requesting a SEMUNDO would be exceeded.

    [EINVAL]  The number of individual semaphores for which the calling pro-
              cess requests a SEMUNDO would exceed the UNIX operating system
              limit.

    [ERANGE]  An operation would cause a semval to overflow the UNIX operat-
              ing system-imposed limit.

    [ERANGE]  An operation would cause a semadj value to overflow the UNIX
              operating system-imposed limit.

    [EFAULT]  sops points to an illegal address.

    On successful completion, the value of semid for each semaphore specified
    in the array pointed to by sops is set to the process ID of the DOS
    server.

 Return value

    On successful completion, the value of semval at the time of the call for
    the last operation in the array pointed to by sops returns.

    If semop returns due to the removal of a semid from the system, a value
    of -1 returns and errno is set to EIDRM.

    Otherwise, a value of -1 returns and errno is set to indicate the error.

 See also

    dflthost(PCI), Intro(PCI), semctl(PCI), semget(PCI), sleeph(PCI)

 Bugs

    Any requested UNDO operations will occur on a particular host when you
    log out of that host, rather than when the DOS application exits.

 Difference from System V

    Only nonblocking operations are allowed from DOS programs.  If a condi-
    tion arises that would cause the DOS process to block, the function
    returns an error.  Use sleeph to suspend a DOS program.


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