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

  man pages->HP-UX 11i man pages -> msem_lock (2)              
Title
Content
Arch
Section
 

Contents


 msem_lock(2)                                                   msem_lock(2)




 NAME    [Toc]    [Back]
      msem_lock - lock a semaphore

 SYNOPSIS    [Toc]    [Back]
      #include <sys/mman.h>

      int msem_lock(msemaphore *sem, int condition);

 DESCRIPTION    [Toc]    [Back]
      msem_lock() attempts to lock a binary semaphore.

      sem points to an msemaphore structure which specifies the semaphore to
      be locked.

      If the semaphore is not currently locked, it becomes locked and the
      function returns successfully.

      If the semaphore is currently locked, and condition is MSEM_IF_NOWAIT,
      then the function returns with an error.  If the semaphore is
      currently locked and condition is zero, the function does 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 uniquely identifies the semaphore.  If the
      msemaphore structure contains any value copied from an msemaphore
      structure at a different address, the result is undefined.

 IMPLEMENTATION NOTES    [Toc]    [Back]
      If blocked on a locked semaphore, msem_lock() suspends the calling
      process at a priority such that the process can be interrupted by a
      signal.

      The system attempts to ignore or recover from invalid values written
      to the msemaphore structure, but this is not guaranteed for all cases.

      msem_lock() successfully acquires a semaphore that is locked by a
      process that has exited.

 RETURN VALUE    [Toc]    [Back]
      Upon success, msem_lock() returns zero; otherwise, it returns -1 and
      sets errno to indicate the error.

 ERRORS    [Toc]    [Back]
      msem_lock() fails if any of the following conditions are encountered:



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 msem_lock(2)                                                   msem_lock(2)




           [EAGAIN]       MSEM_IF_NOWAIT was specified and the semaphore was
                          already locked.

           [EINVAL]       sem points to an msemaphore structure that has
                          been removed, or condition is invalid.

           [EINTR]        msem_lock() was interrupted by a signal that was
                          caught.

           [EDEADLK]      The semaphore is currently locked, condition is
                          zero, and waiting to lock the semaphore would
                          create a deadlock.

           [EFAULT]       sem is not a properly aligned address or is
                          otherwise an invalid pointer.

 AUTHOR    [Toc]    [Back]
      msem_lock() was developed by HP and OSF.

 SEE ALSO    [Toc]    [Back]
      msem_init(2), msem_remove(2), msem_unlock(2), mman(5).

 STANDARDS CONFORMANCE    [Toc]    [Back]
      msem_lock(): AES


 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003
[ 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