root / lab4 / .minix-src / include / ddekit / semaphore.h @ 13
History | View | Annotate | Download (1018 Bytes)
1 | 13 | up20180614 | #ifndef _DDEKIT_SEMAPHORE_H
|
---|---|---|---|
2 | #define _DDEKIT_SEMAPHORE_H
|
||
3 | |||
4 | #include <ddekit/ddekit.h> |
||
5 | |||
6 | |||
7 | /** \defgroup DDEKit_synchronization */
|
||
8 | |||
9 | struct ddekit_sem;
|
||
10 | typedef struct ddekit_sem ddekit_sem_t; |
||
11 | |||
12 | /** Initialize DDEKit semaphore.
|
||
13 | *
|
||
14 | * \ingroup DDEKit_synchronization
|
||
15 | *
|
||
16 | * \param value initial semaphore counter
|
||
17 | */
|
||
18 | ddekit_sem_t *ddekit_sem_init(int value);
|
||
19 | |||
20 | /** Uninitialize semaphore.
|
||
21 | *
|
||
22 | * \ingroup DDEKit_synchronization
|
||
23 | */
|
||
24 | void ddekit_sem_deinit(ddekit_sem_t *sem);
|
||
25 | |||
26 | /** Semaphore down method. */
|
||
27 | void ddekit_sem_down(ddekit_sem_t *sem);
|
||
28 | |||
29 | /** Semaphore down method, non-blocking.
|
||
30 | *
|
||
31 | * \ingroup DDEKit_synchronization
|
||
32 | *
|
||
33 | * \return 0 success
|
||
34 | * \return !=0 would block
|
||
35 | */
|
||
36 | int ddekit_sem_down_try(ddekit_sem_t *sem);
|
||
37 | |||
38 | /** Semaphore down with timeout.
|
||
39 | *
|
||
40 | * \ingroup DDEKit_synchronization
|
||
41 | *
|
||
42 | * \return 0 success
|
||
43 | * \return !=0 would block
|
||
44 | */
|
||
45 | int ddekit_sem_down_timed(ddekit_sem_t *sem, int timo); |
||
46 | |||
47 | /** Semaphore up method.
|
||
48 | *
|
||
49 | * \ingroup DDEKit_synchronization
|
||
50 | */
|
||
51 | void ddekit_sem_up(ddekit_sem_t *sem);
|
||
52 | |||
53 | #endif |