23 lines
481 B
C
23 lines
481 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;
|
|
int32_t count;
|
|
};
|
|
|
|
uint8_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, int32_t count);
|
|
|
|
#endif /* _SEMSPHORE_H_ */
|