我的框中的下列值:
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,我搜索了它并得到了解释:
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,这意味着每一个SCHED_OTHER在被抢占之前得到0.01秒的运行时间,除非它被阻塞套接字或睡眠或其他方式阻塞,这意味着如果在核心1中有3个任务--例如,2个带有SCHED_RR的任务,第三个带有SCHED_OTHER的任务,第三个任务只是运行一个没有阻塞套接字的连续循环,并且没有产生任何影响,那么第三个任务一旦获得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任务可以抢占无止境的时间循环,甚至连时间片都没有完成?!
发布于 2016-09-09 16:55:05
具有较高调度类“优先级”的任务将抢占优先级较低的所有任务,而不考虑任何超时。下面看一下内核/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将按以下顺序返回类:停止、截止日期、rt、公平、空闲。当试图抢占具有与抢占任务相同的调度类的任务时,循环将停止。
因此,对于你的问题,答案是肯定的,一个"rt“任务将抢先一项”公平“的任务。
https://stackoverflow.com/questions/38136641
复制相似问题