2008-02-23 00:25:31 +01:00
|
|
|
#ifndef _SEMSPHORE_H_
|
|
|
|
#define _SEMSPHORE_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "rtos/context.h"
|
|
|
|
#include "rtos/spinlock.h"
|
|
|
|
|
|
|
|
struct semaphore {
|
|
|
|
struct context *sleep_queue;
|
|
|
|
struct spinlock lock;
|
2008-02-24 20:07:46 +01:00
|
|
|
int32_t count;
|
2008-02-23 00:25:31 +01:00
|
|
|
};
|
|
|
|
|
2008-02-24 20:07:46 +01:00
|
|
|
uint8_t sem_wait(struct semaphore *sem);
|
2008-02-23 00:25:31 +01:00
|
|
|
void sem_post(struct semaphore *sem);
|
|
|
|
|
|
|
|
void sem_interrupt(struct semaphore *sem, struct context *c);
|
|
|
|
int32_t sem_get_count(struct semaphore *sem);
|
2008-02-24 20:07:46 +01:00
|
|
|
void sem_init(struct semaphore *sem, int32_t count);
|
2008-02-23 00:25:31 +01:00
|
|
|
|
|
|
|
#endif /* _SEMSPHORE_H_ */
|