Reputation: 127
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.
Upvotes: 4
Views: 16176
Reputation: 1
Timer interruption is a technique that is closely related to preemption. when a process gets the CPU, a timer may be set to a specified interval. If the process is still using the CPU at the end of the interval, then it is preempted.
Upvotes: 0
Reputation: 21667
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:
Upvotes: 3
Reputation: 8292
does the scheduler actually run on every interval?
Yes and No, the scheduler will run only when interrupt
occurs. Also I think there is a misunderstanding. Let me clear that up.
In every time interval,interrupt is not made, but the interrupt input is checked(for level-triggered interrupts), and if interrupt occurs in that interval only then scheduler runs, it does not run if there is no interrupt in that interval.
What is the role of DPC here and is it related to the scheduler?
Quoting from the Wikipedia
A Deferred Procedure Call (DPC) is a Microsoft Windows operating system mechanism which allows high-priority tasks (e.g. an interrupt handler) to defer required but lower-priority tasks for later execution. This permits device drivers and other low-level event consumers to perform the high-priority part of their processing quickly, and schedule non-critical additional processing for execution at a lower priority.
Clearly, DPC is not related to scheduler, because its job is to decide what to run next on the CPU whereas DPC is a mechanism for a processor to delay execution of low priority process.
Upvotes: 1