wait_queue.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <common/glib.h>
  3. // #include <common/spinlock.h>
  4. // #include <process/process.h>
  5. /**
  6. * @brief 信号量的等待队列
  7. *
  8. */
  9. typedef struct
  10. {
  11. struct List wait_list;
  12. struct process_control_block *pcb;
  13. } wait_queue_node_t;
  14. /**
  15. * @brief 初始化等待队列
  16. *
  17. * @param wait_queue 等待队列
  18. * @param pcb pcb
  19. */
  20. void wait_queue_init(wait_queue_node_t *wait_queue, struct process_control_block *pcb);
  21. /**
  22. * @brief 在等待队列上进行等待
  23. *
  24. * @param wait_queue_head 队列头指针
  25. */
  26. void wait_queue_sleep_on(wait_queue_node_t * wait_queue_head);
  27. /**
  28. * @brief 在等待队列上进行等待,同时释放自旋锁
  29. *
  30. * @param wait_queue_head 队列头指针
  31. */
  32. void wait_queue_sleep_on_unlock(wait_queue_node_t *wait_queue_head,
  33. void *lock);
  34. /**
  35. * @brief 在等待队列上进行等待(允许中断)
  36. *
  37. * @param wait_queue_head 队列头指针
  38. */
  39. void wait_queue_sleep_on_interriptible(wait_queue_node_t * wait_queue_head);
  40. /**
  41. * @brief 唤醒在等待队列的头部的进程
  42. *
  43. * @param wait_queue_head 队列头
  44. * @param state 要唤醒的进程的状态
  45. */
  46. void wait_queue_wakeup(wait_queue_node_t * wait_queue_head, int64_t state);