sam7fc/include/rtos/semaphore.h

23 lines
500 B
C

#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;
uint32_t count;
};
state_t sem_wait(struct semaphore *sem);
void sem_post(struct semaphore *sem);
void sem_interrupt(struct semaphore *sem, struct context *c);
int32_t sem_get_count(struct semaphore *sem);
void sem_init(struct semaphore *sem, uint8_t priority, int32_t count);
#endif /* _SEMSPHORE_H_ */