1.2.1 Operating System - Interrupts and Polling Flashcards
What are the two ways of the CPU knowing when a device needs its attention?
Interrupts and Polling
What is Polling?
Polling is when the CPU keeps checking each peripheral to see if it needs attention. This is often inefficient as the CPU is almost ‘wasting its time’ if none need attention.
What is Interrupts?
Interrupts is an alternative to polling, and is when a device sends a signal to the processor. Interrupts have priority indicating how urgently it requires attention.
When the interrupt is raised, the OS runs the relevant Interrupt Service Routine.
When does the OS check to see if there any any interrupts?
At the end of every F-D-E cycle, the OS checks to see if there are any interrupts, halting the current task if there are any of higher priority.
What are the 3 steps performed after the interrupt priority is checked against the priority of the current task and proven to be higher?
- The contents of the program counter and other registers are copied to an area of memory called a stack
- The relevant ISR (Interrupt Service Routine) can then be loaded by changing the PC value to the value of where the ISR starts
- When the ISR is complete, the previous values of the PC and registers are restored from memory to the CPU
What is a stack overflow?
A stack overflow is when interrupts continually interrupt interrupts, and stack memory becomes full with the values of the registers from those interrupts.