1

I understand the notion of update_rq_clock as it updates the run queue clock on system tick periodically. But this function calls update_rq_clock_task(). What is the purpose behind this function?

1 Answers1

1

Within update_rq_clock the difference between the CPU timestamp and the run queue clock is calculated (The rq->clock variable represents the last clock read from the CPU). That difference is added to the rq->clock and to the rq->clock_task (Which is the same as rq->clock - time for interrupts and stolen time) through update_rq_clock_task.

There are a couple of options within the function, which you can activate with kernel build options. But basically it breaks down to:

...
rq->clock_task += delta;
...
update_rq_clock_pelt(rq, delta);
...

So, both functions together update the clock of the run queue and the clock of the run queue without accounting for interrupts and stolen time (unless you activated that accounting through the kernel options), so the actual time that the tasks used.

initBasti
  • 11
  • 2
  • 4
  • when a system tick occurs, if the system executes the scheduler code, are other interrupts disabled? I encountered a statement "In the absence of any other interrupt, the scheduler will run whenever the clock interrupt fires". so even the more higher priority interrupts are not executed? – Lucifer Poltergeist Jul 17 '20 at 19:02
  • That statement refers to cases when the scheduler is invoked and means: The scheduler will be invoked whenever the timer interrupt fires OR whenever another interrupt interacts with the scheduler. About the other question: "when a system tick occurs, if the system executes the scheduler code, are other interrupts disabled?" As stated by the description of the `scheduler_tick` function: "This function gets called by the timer code, with HZ frequency. We call it with interrupts disabled.". So, the scheduler tick, and therefore the update of the clocks is handled without enabled interrupts. – initBasti Jul 18 '20 at 05:34