Collaboration diagram for Semaphore:
Detailed Description
Thread synchronization support.
In addition to posting and waiting for events, Threads can use the provided semaphore funxtions to handle a pool of shared resources.
|
Data Structures |
| struct | _SEM |
| struct | _mutex |
| | Recursive mutex. More...
|
Typedefs |
|
typedef _SEM | SEM |
| | Sempahore type.
|
Functions |
|
void | NutSemInit (SEM *sem, short value) |
| | Initialize an unnamed semaphore to value.
|
| void | NutSemWait (SEM *sem) |
| | Lock a semaphore.
|
| int | NutSemTryWait (SEM *sem) |
| | Attempt to lock a semaphore without blocking.
|
| void | NutSemPost (SEM *sem) |
| | Unlock a sempahore.
|
| int | NutSemDestroy (SEM *sem) |
| | Free resources allocated for a semaphore.
|
Function Documentation
| int NutSemDestroy |
( |
SEM * |
sem |
) |
|
|
|
|
Free resources allocated for a semaphore.
Return zero, if successful, otherwise there are threads blocked on the sempahore |
| void NutSemPost |
( |
SEM * |
sem |
) |
|
|
|
|
Unlock a sempahore.
: Should not be called from interrupt context |
| int NutSemTryWait |
( |
SEM * |
sem |
) |
|
|
|
|
Attempt to lock a semaphore without blocking.
Return zero, if successful, otherwise the sempahore is already locked : Should not be called from interrupt context |
| void NutSemWait |
( |
SEM * |
sem |
) |
|
|
|
|
Lock a semaphore.
If the semaphore value is currently zero, then the calling thread will not return from the call to sem_wait() the semaphore becomes available
: Should not be called from interrupt context |