struct task_struct {
//进程的当前运行状态
volatile long state;/* -1 unrunnable, 0 runnable, >0 stopped */
unsigned int ags;/* per process ags, dened below */
//动态优先级,静态优先级和常规优先级
int prio, static_prio, normal_prio;
//实时优先级
unsigned int rt_priority;
const struct sched_class *sched_class;/*
调度类指针,一堆指向函数的指针
*/
//CFS
调度实体
struct sched_entity se;
//
实时调度实体
struct sched_rt_entity rt;
unsigned int policy;/*进程的调度类型*/
struct list_head tasks;/*进程组织链表*/
/*上下文切换次数*/
unsigned long nvcsw, nivcsw; /* context switch counts */
}
2 sched_class,
进程调度类
:
包括 fair_sched_class,rt_sched_class 和 idle_sched_class,它们调用的顺序是:
(1)rq->nr_running == rq->cfs.nr_running 说明没有实时进程,就去执行
fair_sched_class 的 pick_next_task()
if (likely(rq->nr_running == rq->cfs.nr_running)) {
p = fair_sched_class.pick_next_task(rq);
if (likely(p))
return p;
}
(2)
/*有实时进程,切换到实时调度类*/
class = sched_class_highest;/*这里就默认实时进程类了*/
for ( ; ; ) {
p = class->pick_next_task(rq);
/*是什么导致了 rq->nr_running != rq->cfs.nr_running,
但是 rt_rq->rt_nr_running=0 呢*/
if (p)
return p;
/*
* Will never be NULL as the idle class always
* returns a non-NULL p: