sched.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <common/glib.h>
  3. #include <process/process.h>
  4. /*
  5. * Scheduling policies
  6. */
  7. #define SCHED_NORMAL 0
  8. #define SCHED_FIFO 1
  9. #define SCHED_RR 2
  10. #define SCHED_BATCH 3
  11. /* SCHED_ISO: reserved but not implemented yet */
  12. #define SCHED_IDLE 5
  13. #define SCHED_DEADLINE 6
  14. #define SCHED_MAX_POLICY_NUM SCHED_DEADLINE
  15. #define IS_VALID_SCHED_POLICY(_policy) ((_policy) > 0 && (_policy) <= SCHED_MAX_POLICY_NUM)
  16. // struct sched_param
  17. // {
  18. // int sched_priority;
  19. // };
  20. // struct sched_attr
  21. // {
  22. // uint32_t size;
  23. // uint32_t sched_policy;
  24. // uint64_t sched_flags;
  25. // /* SCHED_NORMAL, SCHED_BATCH */
  26. // int32_t sched_nice;
  27. // /* SCHED_FIFO, SCHED_RR */
  28. // uint32_t sched_priority;
  29. // /* SCHED_DEADLINE */
  30. // uint64_t sched_runtime;
  31. // uint64_t sched_deadline;
  32. // uint64_t sched_period;
  33. // /* Utilization hints */
  34. // uint32_t sched_util_min;
  35. // uint32_t sched_util_max;
  36. // };
  37. // static int __sched_setscheduler(struct process_control_block *p, const struct sched_attr *attr, bool user, bool pi);
  38. // static int _sched_setscheduler(struct process_control_block *p, int policy, const struct sched_param *param,
  39. // bool check);
  40. // /**
  41. // * sched_setscheduler -设置进程的调度策略
  42. // * @param p 需要修改的pcb
  43. // * @param policy 需要设置的policy
  44. // * @param param structure containing the new RT priority. 目前没有用
  45. // *
  46. // * @return 成功返回0,否则返回对应的错误码
  47. // *
  48. // */
  49. // int sched_setscheduler(struct process_control_block *p, int policy, const struct sched_param *param);
  50. /**
  51. * @brief 包裹sched_enqueue(),将PCB加入就绪队列
  52. *
  53. * @param pcb
  54. */
  55. // ================= Rust 实现 =============
  56. extern void sched_update_jiffies();
  57. extern void sched_init();
  58. extern void sched();
  59. extern void sched_enqueue(struct process_control_block *pcb);
  60. extern void sched();
  61. void switch_proc(struct process_control_block *prev, struct process_control_block *proc);