我的框中的以下值:
sysctl -A | grep "sched" | grep -v "domain"
kernel.sched_autogroup_enabled = 0
kernel.sched_cfs_bandwidth_slice_us = 5000
kernel.sched_child_runs_first = 0
kernel.sched_latency_ns = 18000000
kernel.sched_migration_cost_ns = 5000000
kernel.sched_min_granularity_ns = 10000000
kernel.sched_nr_migrate = 32
kernel.sched_rr_timeslice_ms = 100
kernel.sched_rt_period_us = 1000000
kernel.sched_rt_runtime_us = 950000
kernel.sched_shares_window_ns = 10000000
kernel.sched_time_avg_ms = 1000
kernel.sched_tunable_scaling = 1
kernel.sched_wakeup_granularity_ns = 3000000
这意味着在一秒内,0.95秒用于SCHED_FIFO或SCHED_RR, 只有0.05为SCHED_OTHER保留,我很好奇是什么 sched_wakeup_granularity_ns,我用Google搜索并得到解释:
Ability of tasks being woken to preempt the current task.
The smaller the value, the easier it is for the task to force the preemption
我认为sched_wakeup_granularity_ns只影响SCHED_OTHER任务, SCHED_FIFO和SCHED_RR不应处于睡眠模式,因此无需“唤醒”, 我是对的吗?!
和sched_min_granularity_ns,解释是:
Minimum preemption granularity for processor-bound tasks.
Tasks are guaranteed to run for this minimum time before they are preempted
我想知道,虽然SCHED_RR任务可以拥有95%的cpu时间,但是 由于sched_min_granularity_ns值= 10000000,因此为0.01秒, 这意味着每个SCHED_OTHER在抢占之前运行0.01秒的时间片,除非它被阻塞套接字或睡眠阻塞,否则,这意味着如果我在核心1中有3个任务,例如2个具有SCHED_RR的任务,那么第三个任务是SCHED_OTHER ,第三个任务只是运行一个无限循环而不阻塞套接字recv而没有屈服,所以一旦第三个任务得到cpu并运行,它将运行0.01秒 然后上下文切换出来,即使下一个任务优先于SCHED_RR, 这是sched_min_granularity_ns用法的正确理解吗?!
编辑:
http://lists.pdxlinux.org/pipermail/plug/2006-February/045495.html
描述:
No SCHED_OTHER process may be preempted by another SCHED_OTHER process.
However a SCHED_RR or SCHED_FIFO process will preempt SCHED_OTHER
process before their time slice is done. So a SCHED_RR process
should wake up from a sleep with fairly good accuracy.
表示SCHED_RR任务可以抢占无限循环而不会阻塞偶数 时间片没有完成?!
答案 0 :(得分:2)
具有更高调度级别"优先级"的任务无论任何超时,都将抢占具有较低优先级调度类的所有任务。请查看kernel / sched / core.c中的以下代码段:
void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
{
const struct sched_class *class;
if (p->sched_class == rq->curr->sched_class) {
rq->curr->sched_class->check_preempt_curr(rq, p, flags);
} else {
for_each_class(class) {
if (class == rq->curr->sched_class)
break;
if (class == p->sched_class) {
resched_curr(rq);
break;
}
}
}
/*
* A queue event has occurred, and we're going to schedule. In
* this case, we can save a useless back to back clock update.
*/
if (task_on_rq_queued(rq->curr) && test_tsk_need_resched(rq->curr))
rq_clock_skip_update(rq, true);
}
for_each_class将按此顺序返回类:stop,deadline,rt,fair,idle。当尝试使用与抢占任务相同的调度类来抢占任务时,循环将停止。
所以对于你的问题,答案是肯定的," rt"任务将取代公平"任务。