2011-02-25 13:31:20 +01:00
|
|
|
#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
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
ddekit_sem_t *ddekit_sem_init(int value);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Uninitialize semaphore.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_synchronization
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_sem_deinit(ddekit_sem_t *sem);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Semaphore down method. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_sem_down(ddekit_sem_t *sem);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Semaphore down method, non-blocking.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_synchronization
|
|
|
|
*
|
|
|
|
* \return 0 success
|
|
|
|
* \return !=0 would block
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_sem_down_try(ddekit_sem_t *sem);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Semaphore down with timeout.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_synchronization
|
|
|
|
*
|
|
|
|
* \return 0 success
|
|
|
|
* \return !=0 would block
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_sem_down_timed(ddekit_sem_t *sem, int timo);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Semaphore up method.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_synchronization
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_sem_up(ddekit_sem_t *sem);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
#endif
|