*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> sem_post (3)              
Title
Content
Arch
Section
 

sem_post(3)

Contents


NAME    [Toc]    [Back]

       sem_post - Unlocks a semaphore (P1003.1b)

SYNOPSIS    [Toc]    [Back]

       #include <semaphore.h>

       int sem_post ( sem_t *sem);


LIBRARY    [Toc]    [Back]

       Realtime Library (librt.so, librt.a)

PARAMETERS    [Toc]    [Back]

       Pointer to the semaphore to be unlocked.

DESCRIPTION    [Toc]    [Back]

       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.

RETURN VALUES    [Toc]    [Back]

       On successful completion, the  sem_post  function  returns
       the  value 0 (zero) and performs a semaphore unlock operation,
 unblocking a process.

       Otherwise, the function returns  the  value  -1  and  sets
       errno  to  indicate the error.  The state of the semaphore
       remains unchanged.

ERRORS    [Toc]    [Back]

       The sem_post function fails under the following condition:
       The sem does not refer to a valid semaphore.





SEE ALSO    [Toc]    [Back]

      
      
       Functions: sem_trywait(3), sem_wait(3)

       Guide to Realtime Programming



                                                      sem_post(3)
[ Back ]
 Similar pages
Name OS Title
mlock Tru64 Locks or unlocks a specified region in memory (P1003.1b)
munlock Tru64 Locks or unlocks a specified region in memory (P1003.1b)
munlockall Tru64 Locks into memory, or unlocks, all of a specified process's pages (P1003.1b)
mlockall Tru64 Locks into memory, or unlocks, all of a specified process's pages (P1003.1b)
sem_getvalue Tru64 Gets the value of a specified semaphore (P1003.1b)
sem_unlink Tru64 Removes the specified named semaphore (P1003.1b)
sem_close Tru64 Deallocates the specified named semaphore (P1003.1b)
sem_init Tru64 Initializes an unnamed semaphore (P1003.1b)
sem_destroy Tru64 Destroys an unnamed semaphore (P1003.1b)
sem_open Tru64 Opens/creates a named semaphore for use by a process (P1003.1b)
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service