wait_queue.h 968 B

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