_lwp_mutex_lock(2) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

_lwp_mutex_lock(2)

_lwp_mutex_lock(2)               System Calls               _lwp_mutex_lock(2)

NAME
       _lwp_mutex_lock,  _lwp_mutex_unlock, _lwp_mutex_trylock - mutual exclu‐
       sion

SYNOPSIS
       #include <sys/lwp.h>

       int _lwp_mutex_lock(lwp_mutex_t *mp);


       int _lwp_mutex_trylock(lwp_mutex_t *mp);


       int _lwp_mutex_unlock(lwp_mutex_t *mp);

DESCRIPTION
       These functions serialize the execution of lightweight processes.  They
       are useful for ensuring that only one lightweight process can execute a
       critical  section  of  code at any one time (mutual exclusion). LWP mu‐
       texes must be initialized to 0 before use.


       The _lwp_mutex_lock() function locks the LWP mutex pointed to by mp. If
       the mutex is already locked, the calling LWP blocks until the mutex be‐
       comes available. When _lwp_mutex_lock() returns, the  mutex  is  locked
       and the calling LWP is the "owner".


       The  _lwp_mutex_trylock()  function  attempts to lock the mutex. If the
       mutex is already locked it returns with an error. If the mutex  is  un‐
       locked, it is locked and _lwp_mutex_trylock() returns.


       The _lwp_mutex_unlock() function unlocks a locked mutex. The mutex must
       be  locked and the calling LWP must be the one that last locked the mu‐
       tex (the owner). If any other LWPs are waiting for the mutex to  become
       available, one of them is unblocked.

RETURN VALUES
       Upon  successful  completion, 0 is returned. A non-zero value indicates
       an error.

ERRORS
       If any of the following  conditions  are  detected,  _lwp_mutex_lock(),
       _lwp_mutex_trylock(),  and _lwp_mutex_unlock() fail and return the cor‐
       responding value:

       EINVAL    The mp argument points to an invalid LWP mutex.


       EFAULT    The mp argument points to an illegal address.



       If any of the following conditions  occur,  _lwp_mutex_trylock()  fails
       and returns the corresponding value:

       EBUSY    The mp argument points to a locked mutex.


USAGE
       Most  software  should use the standard interfaces described in the mu‐
       tex(7) and threads(7) manual pages instead of  these  low-level  system
       calls.

SEE ALSO
       _lwp_cond_wait(2), Intro(2), mutex(7), threads(7)

HISTORY
       The  _lwp_mutex_lock(),  _lwp_mutex_trylock(),  and _lwp_mutex_unlock()
       functions were added in Solaris 2.2.

Oracle Solaris 11.4               30 Jan 2023               _lwp_mutex_lock(2)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3