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