1 #ifndef _DDEKIT_SEMAPHORE_H
2 #define _DDEKIT_SEMAPHORE_H
4 #include <ddekit/ddekit.h>
7 /** \defgroup DDEKit_synchronization */
10 typedef struct ddekit_sem ddekit_sem_t
;
12 /** Initialize DDEKit semaphore.
14 * \ingroup DDEKit_synchronization
16 * \param value initial semaphore counter
18 ddekit_sem_t
*ddekit_sem_init(int value
);
20 /** Uninitialize semaphore.
22 * \ingroup DDEKit_synchronization
24 void ddekit_sem_deinit(ddekit_sem_t
*sem
);
26 /** Semaphore down method. */
27 void ddekit_sem_down(ddekit_sem_t
*sem
);
29 /** Semaphore down method, non-blocking.
31 * \ingroup DDEKit_synchronization
34 * \return !=0 would block
36 int ddekit_sem_down_try(ddekit_sem_t
*sem
);
38 /** Semaphore down with timeout.
40 * \ingroup DDEKit_synchronization
43 * \return !=0 would block
45 int ddekit_sem_down_timed(ddekit_sem_t
*sem
, int timo
);
47 /** Semaphore up method.
49 * \ingroup DDEKit_synchronization
51 void ddekit_sem_up(ddekit_sem_t
*sem
);