《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
360 B

12 years ago
  1. #ifndef __KERN_SYNC_SEM_H__
  2. #define __KERN_SYNC_SEM_H__
  3. #include <defs.h>
  4. #include <atomic.h>
  5. #include <wait.h>
  6. typedef struct {
  7. int value;
  8. wait_queue_t wait_queue;
  9. } semaphore_t;
  10. void sem_init(semaphore_t *sem, int value);
  11. void up(semaphore_t *sem);
  12. void down(semaphore_t *sem);
  13. bool try_down(semaphore_t *sem);
  14. #endif /* !__KERN_SYNC_SEM_H__ */