So I realize that I need to utilize timer interrupts in order to make a timer on my Arduino. I have four leds that I want to light up in 5 second increments. I was kind of hoping for help on getting something like that to work?
Videos
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:
- Process queues asynchronous I/O request . . . passage of time.
- Process is executing again.
- An interrupt occurs when the I/O request completes. The OS responds by queuing to the process. 4.Process is executing again
- Timer interrupt goes off. Interrupt handler causes the asynchronous notification to the process to occur.
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.