os_kernel_lab/labcodes/lab7/kern/sync/sem.h

20 lines
360 B
C
Raw Normal View History

2012-08-22 12:32:13 +08:00
#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__ */