General Info | |
Interface: Semaphore Files: lib/semaphore.h Last change: 23/12/2001 Author: Luiz Henrique Shigunov |
Description
Structures |
Functions | |
|
|
This page describes Semaphore user interface.
Semaphores are usually used to control the use of shared resources.
count is the semaphore count and data are specific data and must be initialized with Init.
int Destroy(Semaphore *s);
This function destroys semaphore s, freeing its resources.
The semaphore can't be in use.
typedef struct {
int count;
unsigned int data[3];
} Semaphore;
0x00 - Destroy
Syntax
Description
Return value
int Init(Semaphore *s, int value, int prop);
This function initializes semaphore s with count value and properties prop.
prop isn't used yet.
int P(Semaphore *s);
This function locks semaphore s.
If the semaphore count is less or equal to 0, P blocks the calling thread until count becomes positive.
int TryP(Semaphore *s);
This functions tries to lock semaphore s.
It behaves identically to P, but returns an error if the thread would block.
int V(Semaphore *s);
This function unlocks semaphore s.