上文讲了cfs调度,今天来简单说下实时调度,它本身相对于cfs会简单一点
其结构代码如下图:
-
const struct sched_class rt_sched_class = {
-
.next = &fair_sched_class,// 看,它下来才是cfs,
-
.enqueue_task = enqueue_task_rt,
-
.dequeue_task = dequeue_task_rt,
-
.yield_task = yield_task_rt,
-
-
.check_preempt_curr = check_preempt_curr_rt,
-
-
.pick_next_task = pick_next_task_rt,
-
.put_prev_task = put_prev_task_rt,
-
.set_next_task = set_next_task_rt,
-
-
...
-
.task_tick = task_tick_rt,
-
-
.get_rr_interval = get_rr_interval_rt,
-
-
.prio_changed = prio_changed_rt,
-
.switched_to = switched_to_rt,
-
-
.update_curr = update_curr_rt,
-
...
-
};
其操作的队列结构为rt_rq:
-
struct rt_rq {
-
struct rt_prio_array active;
-
unsigned int rt_nr_running;
-
unsigned int rr_nr_running;
-
..
-
int rt_queued;
-
-
int rt_throttled;
-
u64 rt_time;
-
u64 rt_runtime;
-
/* Nests inside the rq lock: */
-
raw_spinlock_t rt_runtime_lock;
-
...
-
};
其内部结构就是active这个优先级队列,其定义如下:
-
struct rt_prio_array {
-
DECLARE_BITMAP(bitmap, MAX_RT_PRIO+1); /* include 1 bit for delimiter */
-
struct list_head queue[MAX_RT_PRIO];
-
};
就是根据实时优先级定义了一个位图,位图当中的每一个,对应一个链表,具有相同优先级的所有实时进程都保存在对应的列表当中。其入队和出队就相对简单了,具体实时调度策略有两类,FIFO和RR,其中FIFO可以一直执行,除非自己主动yield,RR就得需要tick相关的定时器来进行调度了~
阅读(4045) | 评论(0) | 转发(0) |