基于androidq的code来看内核调度
2、set_load_weight
static_prio:静态优先级是和nice关联的一个值
静态优先级不会随时间改变,内核不会主动修改它,只能通过系统调用 nice 去修改 static_prio,MAX_RT_PRIO的值是100,static_prio的取值范围是100~139
int prio = p->static_prio - MAX_RT_PRIO; 刚好找到对应的sched_prio_to_weight中的值,所以static_prio
task处于idle状态,他的优先级是固定的3,inv_weight也是固定的
/*
* To aid in avoiding the subversion(颠覆) of "niceness" due to uneven(不均匀) distribution(分配)
* of tasks with abnormal(不正常的) "nice" values across CPUs the contribution(贡献) that
* each task makes to its run queue's load is weighted according to its
* scheduling class and "nice" value. For SCHED_NORMAL tasks this is just a
* scaled version of the new time slice allocation that they receive on time
* slice expiry(到期) etc.
*/
#define WEIGHT_IDLEPRIO 3
#define WMULT_IDLEPRIO &nbs

本文深入探讨了Linux内核调度中的`set_load_weight`函数,重点关注静态优先级`static_prio`与任务权重的关系。内容涉及优先级计算、idle任务的固定权重以及在64位和32位系统中nice值对权重的影响。通过对`scale_load`宏的分析,阐述了不同系统下权重计算的差异。
最低0.47元/天 解锁文章
1531





