sem.c File Reference
Semaphore based synchronization services. More...
#include "sem.h"#include <cfg/compiler.h>#include <struct/list.h>#include <cfg/debug.h>#include <cpu/irq.h>#include <kern/proc.h>#include <kern/proc_p.h>#include <kern/signal.h>Go to the source code of this file.
Functions | |
| void | sem_init (struct Semaphore *s) |
| Initialize a Semaphore structure. | |
| bool | sem_attempt (struct Semaphore *s) |
| Attempt to lock a semaphore without waiting. | |
| void | sem_obtain (struct Semaphore *s) |
| Lock a semaphore. | |
| void | sem_release (struct Semaphore *s) |
| Release a lock on a previously locked semaphore. | |
Detailed Description
Semaphore based synchronization services.
- Version:
- Id
- sem.c 3269 2010-03-25 14:56:23Z arighi
Definition in file sem.c.
Function Documentation
| bool sem_attempt | ( | struct Semaphore * | s | ) |
Attempt to lock a semaphore without waiting.
- Returns:
- true in case of success, false if the semaphore was already locked by someone else.
- Note:
- each call to sem_attempt() must be matched by a call to sem_release().
- See also:
- sem_obtain() sem_release()
| void sem_obtain | ( | struct Semaphore * | s | ) |
Lock a semaphore.
If the semaphore is already owned by another process, the caller process will be enqueued into the waiting list and sleep until the semaphore is available.
- Note:
- Each call to sem_obtain() must be matched by a call to sem_release().
- This routine is optimized for highest speed in the most common case: the semaphore is free or locked by the calling process itself. Rearranging this code is probably a bad idea.
- See also:
- sem_release() sem_attempt()
| void sem_release | ( | struct Semaphore * | s | ) |
Release a lock on a previously locked semaphore.
If the nesting count of the semaphore reaches zero, the next process waiting for it will be awaken.
- Note:
- This routine is optimized for highest speed in the most common case: the semaphore has been locked just once and nobody else was waiting for it. Rearranging this code is probably a bad idea.
- See also:
- sem_obtain() sem_attempt()
