2

Using round-robin scheduling, the kernel provides time slices for different processes / tasks.

It seems that the kernel will initialize a timer, and when the timer times out, this will cause the current task to be interrupted and the kernel then gets control.

How does the kernel know that the timer timeout interrupt should be used to schedule a new task? What if the different timers are used for various different purposes and not just for the scheduler? Where do all the different interrup service routines go? Thanks in advance.

1
  • "Using round-robin scheduling, the kernel…" ? Do you precisely mean scheduling tasks SCHED_RR under the linux' CFS ?
    – MC68020
    Oct 9, 2022 at 9:17

1 Answer 1

0

Answer related to threads running under the >= 2.6.23 linux CFS SCHED_RR scheduling policy.


the kernel provides time slices for different processes / tasks.

This is not precisely true. A better understanding is possible if we reword your statement as follows : For each thread, the scheduler computes some time quantum.

It seems that the kernel will initialize a timer, and when the timer times out, this will cause the current task to be interrupted and the kernel then gets control.

This is wrong. As written earlier, the scheduler only computed some time value. No timer went directly associated, no timer interrupt will get fired when the time quantum is reached.

No worry! The scheduler will run about any time whatever IRQ is fired, which, at the very worst case concerning latency should happen at least at CPU_HZ frequency. And about any time the scheduler runs it considers the run queues and recomputes its red-black trees.

If, at the time the scheduler runs, one SCHED_RR task is running and all other SCHED_RR tasks are blocked (waiting for whatever event) and no other real-time scheduled task of higher priority can run then… that very task won't get scheduled out, possibly running for longer than its associated time quantum.

If another SCHED_RR task can run then, if the running task had got the cpu for an amount of time greater or equal to its time quantum then it will be scheduled out and thrown at the back of the queue (given the lowest priority) while the task that could run is scheduled in.

Your last question is IMHO not related to the principal point of this question and should better be made part of another thread.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .