Events
• After the OS has booted, all entry to the kernel happens as the result
of an event
• event immediately stops current execution
• changes mode to kernel mode, event handler is called
• An event is an “unnatural” change in control flow
• Events immediately stop current execution
• Changes mode, context (machine state), or both
• The kernel defines a handler for each event type
• Event handlers always execute in kernel mode
• The specific types of events are defined by the machine
• In effect, the operating system is one big event handler
OS Control Flow
• When the processor receives an event of a given type, it
• transfers control to handler within the OS
• handler saves program state (PC, registers, etc.)
• handler functionality is invoked
• handler restores program state, returns to program
Categorizing Events
• Two kinds of events, interrupts and exceptions
• Exceptions are caused by executing instructions
• CPU requires software intervention to handle a fault or trap
• Interrupts are caused by an external event
• Device finishes I/O, timer expires, etc.
• Two reasons for events, unexpected and deliberate
• Unexpected events are, well, unexpected
• What is an example?
• Deliberate events are scheduled by OS or application
• Why would this be useful?
This gives us a convenient table:
• Terms may be used slightly differently by various OSes,
CPU architectures…
• No need to “memorize” all the terms
• Software interrupt – a.k.a. async system trap (AST), async
or deferred procedure call (APC or DPC)
• Will cover faults, system calls, and interrupts next
Faults
• Hardware detects and reports “exceptional” conditions
• Page fault, divide by zero, unaligned access
• Upon exception, hardware “faults” (verb)
• Must save state (PC, registers, mode, etc.) so that the faulting
process can be restarted
• Fault exceptions are a performance optimization
• Could detect faults by inserting extra instructions into code
(at a significant performance penalty