《操作系统》的实验代码。
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.

48 lines
1.6 KiB

12 years ago
  1. #ifndef __KERN_SYNC_WAIT_H__
  2. #define __KERN_SYNC_WAIT_H__
  3. #include <list.h>
  4. typedef struct {
  5. list_entry_t wait_head;
  6. } wait_queue_t;
  7. struct proc_struct;
  8. typedef struct {
  9. struct proc_struct *proc;
  10. uint32_t wakeup_flags;
  11. wait_queue_t *wait_queue;
  12. list_entry_t wait_link;
  13. } wait_t;
  14. #define le2wait(le, member) \
  15. to_struct((le), wait_t, member)
  16. void wait_init(wait_t *wait, struct proc_struct *proc);
  17. void wait_queue_init(wait_queue_t *queue);
  18. void wait_queue_add(wait_queue_t *queue, wait_t *wait);
  19. void wait_queue_del(wait_queue_t *queue, wait_t *wait);
  20. wait_t *wait_queue_next(wait_queue_t *queue, wait_t *wait);
  21. wait_t *wait_queue_prev(wait_queue_t *queue, wait_t *wait);
  22. wait_t *wait_queue_first(wait_queue_t *queue);
  23. wait_t *wait_queue_last(wait_queue_t *queue);
  24. bool wait_queue_empty(wait_queue_t *queue);
  25. bool wait_in_queue(wait_t *wait);
  26. void wakeup_wait(wait_queue_t *queue, wait_t *wait, uint32_t wakeup_flags, bool del);
  27. void wakeup_first(wait_queue_t *queue, uint32_t wakeup_flags, bool del);
  28. void wakeup_queue(wait_queue_t *queue, uint32_t wakeup_flags, bool del);
  29. void wait_current_set(wait_queue_t *queue, wait_t *wait, uint32_t wait_state);
  30. #define wait_current_del(queue, wait) \
  31. do { \
  32. if (wait_in_queue(wait)) { \
  33. wait_queue_del(queue, wait); \
  34. } \
  35. } while (0)
  36. #endif /* !__KERN_SYNC_WAIT_H__ */