如何在Linux 2.6.x中计算线程的动态优先级?

如何在Linux 2.6.x中计算线程的动态优先级?,第1张

概述线程(或任务)将通过使用大量CPU来丢失动态优先级,并通过使用较少的CPU获得优先级.如何为n个线程计算这些优先级(使用正常调度策略SCHED_OTHER)?最佳答案引自this The Linux 2.6.8.1 scheduler rewards I/O-bound tasks and punishes CPU-bound tasks by ad

线程(或任务)将通过使用大量cpu来丢失动态优先级,并通过使用较少的cpu获得优先级.如何为n个线程计算这些优先级(使用正常调度策略SCHED_OTHER)?最佳答案引自this

The linux 2.6.8.1 scheduler rewards I/O-bound tasks and punishes
cpu-bound tasks by adding or subtracting from a task’s static
priority. The adjusted priority is called a task’s dynamic priority,
and is accessible via the task’s prio variable (e.g. p->prio where p
is a task). If a task is interactive (the scheduler’s term for I/O
bound),its priority is boosted. If it is a cpu hog,it will get a
penalty. In the linux 2.6.8.1 scheduler,the maximum priority bonus is
5 and the maximum priority penalty is 5. Since the scheduler uses
bonuses and penaltIEs,adjustments to a task’s static priority are
respected. A mild cpu hog with a nice value of -2 might have a dynamic
priority of 0,the same as a task that is neither a cpu nor an I/O
hog.

我觉得这是一个公平的解释.优先级的计算基于cpu绑定线程还是I / O绑定线程.关于你在问题中提到的内容,通过使用较少的cpu获得优先级是通过交互(I / O绑定)获得优先级.我希望这段摘录能回答你的问题…… 总结

以上是内存溢出为你收集整理的如何在Linux 2.6.x中计算线程的动态优先级?全部内容,希望文章能够帮你解决如何在Linux 2.6.x中计算线程的动态优先级?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1050102.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存