Lecture Slides 08 080-Exceptional-Control
Lecture Slides 08 080-Exceptional-Control
Control Flow
Processors do only one thing:
From startup to shutdown, a CPU simply reads and executes (interprets)
a sequence of instructions, one at a time
This sequence is the CPU’s control flow (or flow of control)
Exceptions
An exception is transfer of control to the operating system (OS)
in response to some event (i.e., change in processor state)
User Process OS
Examples:
div by 0, page fault, I/O request completes, Ctrl-C
How does the system know where to jump to in the OS?
Interrupt Vectors
Exception
numbers
code for
exception handler n-1
Synchronous Exceptions
Caused by events that occur as a result of executing an
instruction:
Traps
Intentional: transfer control to OS to perform some function
Examples: system calls, breakpoint traps, special instructions
Returns control to “next” instruction
Faults
Unintentional but possibly recoverable
Examples: page faults (recoverable), segment protection faults
(unrecoverable), integer divide-by-zero exceptions (unrecoverable)
Either re-executes faulting (“current”) instruction or aborts
Aborts
Unintentional and unrecoverable
Examples: parity error, machine check
Aborts current program
Exceptional Control Flow
University of Washington
User Process OS
int exception
pop
open file
returns
User Process OS
User Process OS
Summary
Exceptions
Events that require non-standard control flow
Generated externally (interrupts) or internally (traps and faults)
After an exception is handled, one of three things may happen:
Re-execute the current instruction
Resume execution with the next instruction
Abort the process that caused the exception