Class Hierarchy   Compound List   File List   Compound Members   File Members  

semaphore.h File Reference

POSIX 1003.1b semaphores for process synchronization. More...

Defines

Typedefs

Functions


Detailed Description

POSIX 1003.1b semaphores for process synchronization.

Author(s):
Markus L. Noga <noga@inrialpes.fr>


Function Documentation

int sem_wait (sem_t * sem)

wait on a semaphore.

Parameters:
sem - a valid semaphore

suspends the calling thread until the semaphore has non-zero count. It then atomically decreases the semaphore count.

implemented with wait_event().

int sem_trywait (sem_t * sem)

non-blocking check on a semaphore.

Parameters:
sem - a valid semaphore

a non-blocking variant of sem_wait. If the semaphore has non-zero count, the count is atomically decreased and sem_trywait immediately returns 0. If the semaphore count is zero, sem_trywait immediately returns with error EAGAIN.

this is IRQ handler safe.

int sem_post (sem_t * sem)

increase semaphore count.

Parameters:
sem - a valid semaphore

atomically increases the count of the semaphore. This function never blocks and can safely be used in asynchronous signal handlers.

legOS-0.1.7 is released under Mozilla Public License. Original code © 1998-1999 by Markus L. Noga.