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

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

msem_lock(3)

Contents


NAME    [Toc]    [Back]

       msem_lock - Lock a semaphore

SYNOPSIS    [Toc]    [Back]

       #include <sys/mman.h>

       int msem_lock(
               msemaphore *sem,
               int condition );

LIBRARY    [Toc]    [Back]

       Standard C Library (libc)

PARAMETERS    [Toc]    [Back]

       Points  to  an  msemaphore  structure  which specifies the
       semaphore  to   be   locked.    Determines   whether   the
       msem_lock()   function   waits   for  a  currently  locked
       semaphore to unlock.

DESCRIPTION    [Toc]    [Back]

       The  msem_lock()  function  attempts  to  lock  a   binary
       semaphore.

       If the semaphore is not currently locked, it is locked and
       the msem_lock() function returns successfully.

       If the semaphore is currently locked,  and  the  condition
       parameter is MSEM_IF_NOWAIT, then the msem_lock() function
       returns with an  error.  If  the  semaphore  is  currently
       locked,  and  the  condition  parameter  is 0 (zero), then
       msem_lock() will not return until either the calling  process
  is  able  to  successfully lock the semaphore, or an
       error condition occurs.

       All calls to msem_lock()  and  msem_unlock()  by  multiple
       processes  sharing a common msemaphore structure behave as
       if the calls were serialized.

       If the msemaphore structure contains any value not resulting
  from  a  call  to msem_init() followed by a (possibly
       empty) sequence of calls to msem_lock() and msem_unlock(),
       the  results  are  undefined. The address of an msemaphore
       structure may be significant. If the msemaphore  structure
       contains  any value copied from an msemaphore structure at
       a different address, the result is undefined.

NOTES    [Toc]    [Back]

       Trial use

RETURN VALUES    [Toc]    [Back]

       On successful completion, the msem_lock() function returns
       0  (zero).  On  error, the msem_lock() function returns -1
       and sets errno to indicate the error.

ERRORS    [Toc]    [Back]

       If the msem_lock() function fails, errno may be set to one
       of  the following values: MSEM_IF_NOWAIT was specified and
       the semaphore  was  already  locked.   The  sem  parameter
       points  to  an  msemaphore  structure  which  specifies  a
       semaphore which has been removed, or the condition parameter
  is invalid.  The msem_lock() function was interrupted
       by a signal which was caught.

SEE ALSO    [Toc]    [Back]

      
      
       Functions: msem_init(3), msem_remove(3), msem_unlock(3)



                                                     msem_lock(3)
[ Back ]
 Similar pages
Name OS Title
sem_trywait FreeBSD decrement (lock) a semaphore
sem_trywait OpenBSD decrement (lock) a semaphore
sem_wait OpenBSD decrement (lock) a semaphore
sem_wait FreeBSD decrement (lock) a semaphore
sem_wait HP-UX lock a POSIX semaphore
sem_trywait HP-UX lock a POSIX semaphore
usconfig IRIX semaphore and lock arena configuration operations
sem_wait Tru64 Performs (or conditionally performs) a semaphore lock (P1003.1b)
sem_trywait Tru64 Performs (or conditionally performs) a semaphore lock (P1003.1b)
pthread_rwlock_wrlock IRIX lock a read-write lock object for writing
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service