next up previous contents index
Next: Delay Up: Thread Library Previous: Type Definitions

Synchronization Operations

 

semInit

 

Initializes semaphore sem with a count of count. Semaphores in the kernel are normally allocated statically (i.e., Semaphore x;) and must be initialized (semInit(&x, 1);) before they are used.

void semInit(Semaphore *sem, int count)

semWait

 

Increments the use count for the semaphore. The current thread will either acquire the semaphore sem or give up control until a semSignal is done by another thread and the scheduler runs.

void semWait(Semaphore *sem)

semSignal

 

The current thread decrements the use count for semaphore sem. The current thread continues executing. Note that if multiple threads are blocked on the semaphore, there is no policy about which thread will be awakened by the semSignal.

void semSignal(Semaphore *sem)



Larry Peterson
Tue Jul 1 14:50:34 MST 1997