4 - Interrupts, Traps, Kernel Design, VMs Flashcards
At a LOW level, how do we write programs that interact with devices?
Special I/O instructions
Memory mapped devices
At a HIGH level, how do we write programs that interact with devices?
System calls provided by OS
There are blocking and non blocking versions of system calls
What is I/O busy waiting/spinning/busy looping?
CPU repeatedly checks if device is ready
What are some problems with busy waiting?
CPU is tied up while the slow I/O completes the operation
We are wasting power and generating heat (so what?)
What is I/O busy waiting with delay?
same as busy waiting, we just add a short delay to reduce CPU usage
CPU can do other things while program is sleeping
What are some problems with busy waiting?
- hard to estimate the right amount of sleep
* program might end up running longer than necessary
What are interrupts?
A mechanism to let the CPU know something ‘important’ happened
When the I/O device finishes the operation, it generates an interrupt,
letting the CPU know it’s done, or if there was an error
How is an interrupt handled?
Usually handled immediately
the CPU temporarily suspends its current activity (saves state)
The CPU then executes an ISR
- The CPU puts itself in a kernel mode (privileged mode)
- Which routine[s] gets executed is configured by OS
Eventually CPU restores the saved state and resumes original execution
What is an Interrupt Vector Table?
Each interrupt contains an address of a service routine
What are the two different types if interrupt?
Hardware & Software Interrupts
What are Hardware Interrupts?
The source of the interrupt is another device
Interrupts are UNPREDICATABLE
What are Software Interrupts? (exceptions/traps?)
Source of interrupt is CPU itself
What are the two types of software interrupt?
Intentional and unintentional
What are Unintentional software Interrupts?
EXCEPTIONS
occurs when CPU executes ‘invalid’ instruction
What are Intentional software Interrupts?
TRAPS
the purpose is to execute predefined routine in kernel mode
operating systems use traps to implement system calls