os_kernel_lab/labcodes/lab8/kern/sync/sem.h
2013-09-17 22:21:48 +08:00

20 lines
360 B
C

#ifndef __KERN_SYNC_SEM_H__
#define __KERN_SYNC_SEM_H__
#include <defs.h>
#include <atomic.h>
#include <wait.h>
typedef struct {
int value;
wait_queue_t wait_queue;
} semaphore_t;
void sem_init(semaphore_t *sem, int value);
void up(semaphore_t *sem);
void down(semaphore_t *sem);
bool try_down(semaphore_t *sem);
#endif /* !__KERN_SYNC_SEM_H__ */