summaryrefslogtreecommitdiff
path: root/minix/include/ddekit/semaphore.h
blob: 1f1affe2e4a3a1e25bc4f5e7030ce540a015d192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _DDEKIT_SEMAPHORE_H
#define _DDEKIT_SEMAPHORE_H

#include <ddekit/ddekit.h>


/** \defgroup DDEKit_synchronization */

struct ddekit_sem;
typedef struct ddekit_sem ddekit_sem_t;

/** Initialize DDEKit semaphore.
 *
 * \ingroup DDEKit_synchronization
 *
 * \param value  initial semaphore counter
 */
ddekit_sem_t *ddekit_sem_init(int value);

/** Uninitialize semaphore.
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_sem_deinit(ddekit_sem_t *sem);

/** Semaphore down method. */
void ddekit_sem_down(ddekit_sem_t *sem);

/** Semaphore down method, non-blocking.
 *
 * \ingroup DDEKit_synchronization
 *
 * \return 0   success
 * \return !=0 would block
 */
int ddekit_sem_down_try(ddekit_sem_t *sem);

/** Semaphore down with timeout.
 *
 * \ingroup DDEKit_synchronization
 *
 * \return 0   success
 * \return !=0 would block
 */
int ddekit_sem_down_timed(ddekit_sem_t *sem, int timo);

/** Semaphore up method. 
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_sem_up(ddekit_sem_t *sem);

#endif