sched.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <common/glib.h>
  3. #include <process/process.h>
  4. // @todo: 用红黑树重写cfs的队列
  5. struct sched_queue_t
  6. {
  7. long count; // 当前队列中的数量
  8. long cpu_exec_proc_jiffies; // 进程可执行的时间片数量
  9. struct process_control_block proc_queue;
  10. };
  11. extern struct sched_queue_t sched_cfs_ready_queue[MAX_CPU_NUM]; // 就绪队列
  12. /**
  13. * @brief 调度函数
  14. *
  15. */
  16. void sched_cfs();
  17. /**
  18. * @brief 包裹sched_cfs(),调度函数
  19. *
  20. */
  21. void sched();
  22. /**
  23. * @brief 将PCB加入就绪队列
  24. *
  25. * @param pcb
  26. */
  27. void sched_cfs_enqueue(struct process_control_block *pcb);
  28. /**
  29. * @brief 包裹sched_enqueue(),将PCB加入就绪队列
  30. *
  31. * @param pcb
  32. */
  33. void sched_enqueue(struct process_control_block *pcb);
  34. /**
  35. * @brief 从就绪队列中取出PCB
  36. *
  37. * @return struct process_control_block*
  38. */
  39. struct process_control_block *sched_cfs_dequeue();
  40. /**
  41. * @brief 初始化进程调度器
  42. *
  43. */
  44. void sched_init();
  45. /**
  46. * @brief 当时钟中断到达时,更新时间片
  47. *
  48. */
  49. void sched_update_jiffies();