今天看linux的任务调度发现内核已经考虑了实时性的进程,但是常常听说linux的实时性太差,不知道大家对实时性的时间要求如何?还有就是linux对实时进程的最大最小反映时限如何从理论上计算?
一下是任务调度的两个注意点供参考:
注意linux的任务优先级
在v2.4.30以上的版本考虑到了实时任务和普通任务的区别
在任务调度的的时候分别处理上面的两种任务
如在schedule函数中通过
weight = goodness(p, this_cpu, prev->active_mm);计算权值的时候
对于实时任务最低为1000(weight = 1000 + p->rt_priority;)
注意普通任务的时间片,优先级nice 和权值
详情参考goodness函数
if (p->policy == SCHED_OTHER) {
/*
* Give the process a first-approximation goodness value
* according to the number of clock-ticks it has left.
*
* Don't do any other calculations if the time slice is
* over..
*/
weight = p->counter;
if (!weight)
goto out;
#ifdef CONFIG_SMP
/* Give a largish advantage to the same processor... */
/* (this is equivalent to penalizing other processors) */
if (p->processor == this_cpu)
weight += PROC_CHANGE_PENALTY;
#endif
/* .. and a slight advantage to the current MM */
if (p->mm == this_mm || !p->mm)
weight += 1;
weight += 20 - p->nice;
goto out;
}
nice的值在-20到20之间,越大则优先级越低。
Realtime in operating systems: the ability of the operating system to provide a required level of service in a bounded response time"
A real-time system is one in which the correctness of the computations not only depends upon the logical correctness of the computation but also upon the time at which the result is produced. If the timing constraints of the system are not met, system failure is said to have occurred."