VMS Help  —  CRTL  sem_post
    Unlocks a semaphore.

    This function is OpenVMS Alpha and Integrity servers only.

    Format

      #include  <semaphore.h>

      int sem_post  (sem_t *sem);

1  –  Argument

 sem

    The semaphore to be unlocked.

2  –  Description

    The sem_post function unlocks the specified semaphore by
    performing the semaphore unlock operation on that semaphore. The
    appropriate function (sem_open for named semaphores or sem_init
    for unnamed semaphores) must be called for a semaphore before
    you can call the locking and unlocking functions, sem_wait, sem_
    trywait, and sem_post.

    If the semaphore value after a sem_post function is positive, no
    processes were blocked waiting for the semaphore to be unlocked;
    the semaphore value is incremented. If the semaphore value after
    a sem_post function is zero, one of the processes blocked waiting
    for the semaphore is allowed to return successfully from its call
    to sem_wait.

    If more than one process is blocked while waiting for the
    semaphore, only one process is unblocked and the state of
    the semaphore remains unchanged when the sem_post function
    returns. The process to be unblocked is selected according to
    the scheduling policies and priorities of all blocked processes.
    If the scheduling policy is SCHED_FIFO or SCHED_RR, the highest-
    priority waiting process is unblocked. If more than one process
    of that priority is blocked, then the process that has waited the
    longest is unblocked.

    The sem_post function can be called from a signal-catching
    function.

3  –  Return Values

    0                  Successful completion. The sem_post function
                       performs a semaphore unlock operation,
                       unblocking a process.
    -1                 Indicates an error. The function sets errno to
                       one of the following values:

                       o  EINVAL - The sem argument is not a valid
                          semaphore.

                       o  EVMSERR - OpenVMS specific nontranslatable
                          error code.
Close Help