Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timer interrupt and scheduling

I'm having a hard time understanding the way that timer interrupts relate to the system scheduler and the role of DPC (deferred procedure calls) in all of this. Here's what I understood (Correct me if i'm wrong):

1) At every clock interval an interrupt is made, Causing the current process to pause and the clock interrupt handler starts running after a context switch.

2) The handler runs the scheduler which checks if a certain process ran out of running time or stopped executing because of an IO operation etc...

So my first question is: does the scheduler actually run on every interval?

My second question is: What is the role of DPC here and is it related to the scheduler?

(I tried to understand from Wikipedia but didn't quite understand what's the "dispatching" that's mentioned there)

thanks.

like image 398
Rexi Avatar asked Oct 28 '25 10:10

Rexi


1 Answers

1) At every clock interval an interrupt is made, Causing the current process to pause and the clock interrupt handler starts running after a context switch.

There is no context switch in the interrupt handling. Whatever, process happened to be running at the time handles the interrupt (some OS's use different terminology but it is effectively the same thing).

2) The handler runs the scheduler which checks if a certain process ran out of running time or stopped executing because of an IO operation etc...

That entirely depends up on the operating system. However, it will not check "stopped executing because of an IO operation" because that happens when a blocking I/O operation is queued.

So my first question is: does the scheduler actually run on every interval?

That largely depends one what you consider to be the scheduler. It is also system specific. And it depends upon the relationship between the process quantum and the timer interval.

If one considers checking to see if the process quantum has expired to be part of the scheduler, then you might say the scheduler is likely to run on every timer interval.

My second question is: What is the role of DPC here and is it related to the scheduler?

Interrupt handlers need to be short but for time and stack purposes. Many operating systems schedule events to be delivered to processes. At its core, Windoze, like VMS before it, is a software interrupt driven system. Those can be delivered to the process as part of the timer interrupt.

A sequence like this can occur:

  1. Process queues asynchronous I/O request . . . passage of time.
  2. Process is executing again.
  3. An interrupt occurs when the I/O request completes. The OS responds by queuing to the process. 4.Process is executing again
  4. Timer interrupt goes off. Interrupt handler causes the asynchronous notification to the process to occur.
like image 61
user3344003 Avatar answered Oct 30 '25 10:10

user3344003



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!