xref: /DragonOS/kernel/src/sched/mod.rs (revision 8d72b68da9339ec97e1b8929bcf2946f0fd83cd5)
1 pub mod cfs;
2 pub mod completion;
3 pub mod core;
4 pub mod rt;
5 pub mod syscall;
6 
7 /// 调度策略
8 #[allow(dead_code)]
9 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10 pub enum SchedPolicy {
11     /// 完全公平调度
12     CFS,
13     /// 先进先出调度
14     FIFO,
15     /// 轮转调度
16     RR,
17 }
18 
19 /// 调度优先级
20 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
21 pub struct SchedPriority(i32);
22 
23 impl SchedPriority {
24     const MIN: i32 = 0;
25     const MAX: i32 = 139;
26 
27     /// 创建一个新的调度优先级
28     pub const fn new(priority: i32) -> Option<Self> {
29         if Self::validate(priority) {
30             Some(Self(priority))
31         } else {
32             None
33         }
34     }
35 
36     /// 校验优先级是否合法
37     pub const fn validate(priority: i32) -> bool {
38         priority >= Self::MIN && priority <= Self::MAX
39     }
40 
41     pub fn data(&self) -> i32 {
42         self.0
43     }
44 }
45