sema(9) 맨 페이지 - 윈디하나의 솔라나라

개요

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

sema(9)

Counting  semaphores provide a mechanism for synchronizing access
to a pool of resources.  Unlike mutexes, semaphores do  not  have
the concept of an owner, so they can also be useful in situations
where  one thread needs to acquire a resource, and another thread
needs to release it.  Each semaphore has an integer value associ‐
ated with it.  Posting (incrementing) always succeeds, but  wait‐
ing  (decrementing) can only successfully complete if the result‐
ing value of the semaphore is greater  than  or  equal  to  zero.
Semaphores  should  not be used where mutexes and condition vari‐
ables will suffice.  Semaphores are a more  complex  synchroniza‐
tion  mechanism than mutexes and condition variables, and are not
as efficient.  Semaphores are created with where is a pointer  to
space  for  a  is  the  initial  value of the semaphore, and is a
pointer to a null-terminated character string that describes  the
semaphore.   Semaphores  are destroyed with A semaphore is posted
(incremented) with A semaphore is waited on (decremented) with or
The argument to specifies the minimum time in ticks to  wait  be‐
fore  returning  with failure.  is used to read the current value
of the semaphore.  The function returns the current value of  the
semaphore.   If  decrementing  the  semaphore would result in its
value being negative, returns 0 to indicate failure.   Otherwise,
a  non-zero  value is returned to indicate success.  The function
returns 0 if waiting on the semaphore succeeded; otherwise a non-
zero error code is returned.  The function will fail if:  Timeout
expired.









































맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3