Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ semget(2) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                semget(2)



        _________________________________________________________________
        semget                                                System Call
        Get set of semaphores.
        _________________________________________________________________


        SYNTAX

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

        int   semget  (key, size, flag)
        key_t           key;
        int             size;
        int             flag;


        PARAMETERS

        key            A user-defined name for the semaphore set.


        size           The requested number of semaphores in the
                       semaphore set.


        flag           A set of flags indicating the requested permission
                       state of the semaphore set, whether a new
                       semaphore set should be created, and whether the
                       semaphore set should be held exclusively.


        DESCRIPTION

        Semget returns the semaphore set identifier associated with
        <key>.  This semaphore set identifier may then be used in other
        semaphore set operations as specified by semctl and semop.
        Semget can be used to get the semaphore set identifier of an
        already existing semaphore set or to create a new semaphore set
        with <size> semaphores.

        Four options are available:

        *    Create a private semaphore set.

             In this case, <key> is IPC_PRIVATE.

             A process can create a "private" semaphore set by using the
             special IPC_PRIVATE key.  The system will create a semaphore
             set identifier that is private to the process.  The



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                semget(2)



             semaphore set identifier will not be returned to other
             processes regardless of what key value they specify.

             The newly created semaphore set can be shared among other
             processes by distributing the semaphore set identifier.

             A process can make multiple semget operations specifying
             IPC_PRIVATE.  The keys returned will be unique and the
             associated semaphore sets will be different.

        *    Find <key> if already defined.

             In this case, the IPC_CREAT and IPC_EXCL bits of <flag> are
             clear and <key> is not IPC_PRIVATE.

             The semaphore set identifier associated with the given key
             is returned.  An error is given if one of the following
             conditions hold:

        *    No semaphore set identifier is associated with <key>.

        *    A semaphore set identifier is associated with <key> but the
             permission rights of the semaphore set do not include those
             specified by the low-order 9 bits of <flag>.

        *    A semaphore set identifier is associated with <key> but
             <size> is non-zero and the number of semaphores in the
             semaphore set is less than <size>.

        *    Create only if <key> not already defined.

             In this case, the IPC_CREAT and IPC_EXCL bits of <flag> are
             both set and <key> is not IPC_PRIVATE.

             If a semaphore set identifier already exists for <key> an
             error is returned.  Otherwise, a semaphore set identifier
             and associated semaphore set are created.  The semaphore set
             identifier will be returned to other processes that specify
             the same key value.

        *    Find <key> if already defined, otherwise create.

             In this case, the IPC_CREAT bit of <flag> is set, the
             IPC_EXCL bit of <flag> is clear, and <key> is not
             IPC_PRIVATE.

             If a semaphore set identifier already exists for <key>, this
             is identical to the second option above).  Otherwise, this
             is identical to the third option above.

        If a new semaphore set is created, its attributes are initialized



        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)





                                                                semget(2)



        as follows:

        *    The semaphore set creator's user id (sem_perm.cuid) and the
             semaphore set's user id (sem_perm.uid) are set to the
             effective user id of the calling process.

        *    The semaphore set creator's group id (sem_perm.cgid) and the
             semaphore set's group id (sem_perm.gid) are set to the
             effective group id of the calling process.

        *    The semaphore set's permission rights (in sem_perm.mode) are
             set to the low-order 9 bits of <flag>.

        *    The number of semaphores in the semaphore set (sem_nsems) is
             set to <size>.

        *    The most recent time a semop operation was performed
             (sem_otime) is set to the zero value.

        *    The most recent time the semaphore set attributes were
             changed (sem_ctime) is set to the current time.

        *    The semaphore's value is set to zero.

        *    The process id of the last process to perform an operation
             on the semaphore is set to zero.

        *    The number of processes waiting for the semaphore's value to
             become zero is zero.

        *    The number of processes waiting for the semaphore's value to
             increase is zero.

        *    No processes have a semaphore adjustment value for the
             semaphore.


        ACCESS CONTROL

        None.


        RETURN VALUE

        <id>           A non-negative integer that identifies the
                       semaphore set associated with <key>.


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




        DG/UX 4.00                                                 Page 3
               Licensed material--property of copyright holder(s)





                                                                semget(2)



        EXCEPTIONS

        If a semaphore set identifier exists for <key>, errno may be set
        to one of these values:


        EACCES         The permission rights of the semaphore set do not
                       include those specified by the low-order 9 bits of
                       <flag>.


        EINVAL         <size> is non-zero, and the number of semaphores
                       in the set associated with <key> is less than
                       <size>.


        EEXIST         Both the IPC_CREAT and IPC_EXCL bits of <flag> are
                       set.

        If a semaphore set identifier does not exist for <key>, errno may
        be set to one of these values:


        EINVAL         <Semaphore_set_size> is either less than or equal
                       to zero or greater than the system-imposed limit.


        ENOENT         The IPC_CREAT bit of <flag> is clear.


        ENOSPC         Creating the new semaphore set would cause the
                       system-imposed limit on the maximum number of
                       allowed semaphore sets system-wide to be exceeded.


        SEE ALSO

        The related system calls:  semctl, semop.
        The related manual section:  intro(2).















        DG/UX 4.00                                                 Page 4
               Licensed material--property of copyright holder(s)



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