简体   繁体   English

什么是hrtick_clear(rq); 在linux调度程序?

[英]what is hrtick_clear(rq); in linux scheduler?

while going through linux kernel code inside __scheduler() function I saw hrtick_clear(rq). 通过__scheduler()函数中的linux内核代码,我看到了hrtick_clear(rq)。 Can anyone explain what is this and why it is used? 任何人都可以解释这是什么以及为什么使用它? it seems something related to timer, but unable to proceed further. 它似乎与计时器有关,但无法继续进行。

Classic OS design involves system timer - an entity that ticks at fixed intervals. 经典OS设计涉及系统计时器 - 一个以固定间隔打勾的实体。 During each tick, scheduler is called and if process/thread should be switched. 在每个tick期间,调用调度程序并且应该切换进程/线程。 But system timer frequency is pretty low (ie 1000 HZ, which means once in 1 ms), and if process have only 100us of its timeslice left, it will get extra time (under certain circumstances), while other processes are starve. 但是系统定时器频率非常低(即1000 HZ,这意味着1 ms内一次),如果进程只剩下其时间片的100us,则会获得额外的时间(在某些情况下),而其他进程则处于饥饿状态。

However, modern CPUs provide more precision hardware timers like HPET on Intel, which are provided by hrtimers subsystem. 但是,现代CPU提供了更高精度的硬件定时器,如Intel上的HPET ,由hrtimers子系统提供。 They can be enabled for be used in scheduler by CONFIG_SCHED_HRTICK option. 可以通过CONFIG_SCHED_HRTICK选项启用它们以在调度程序中使用。

But if you already called __schedule() (ie on path of system call), you do not need to call it second time from hrtimer , because you already scheduling, so before doing so, hrtick_clear disables that hrtimer . 但是如果你已经调用__schedule() (即在系统调用的路径上),你不需要从hrtimer第二次调用它,因为你已经安排了,所以在这之前, hrtick_clear禁用了那个hrtimer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM