This preview shows page 1. Sign up to view the full content.
Unformatted text preview: brary Processes 7 University of Washington ExcepJons ¢ An excep&on is transfer of control to the operaJng system (OS) in response to some event (i.e., change in processor state) User Process event I_current I_next OS excep/on • return to I_current • return to I_next • abort excep/on processing by excep&on handler ¢ ¢ Examples: div by 0, page fault, I/O request completes, Ctrl-‐C How does the system know where to jump to in the OS? Processes 8 University of Washington Interrupt Vectors ExcepJon numbers code for excepJon handler 0 ExcepJon Table 0
n-1 ... ¢ code for excepJon handler 1 ¢ code for excepJon handler 2 ¢ ... Each type of event has a unique excepJon number k k = index into excepJon table (a.k.a. interrupt vector) Handler k is called each Jme excepJon k occurs code for excepJon handler n-‐1 Processes 9 University of Washington Asynchronous ExcepJons (Interrupts) ¢ Caused by events external to the processor § Indicated by se`ng the processor’s interrupt pin(s) (wire into CPU) § Handler returns to “next” instruc:on ¢ Examples: § I/O interrupts hi`ng Ctrl-‐C on the keyboard § clicking a mouse buaon or tapping a touchscreen § arrival of a packet from a network § arrival of data from a disk § Hard reset interrupt § hi`ng the reset buaon on front panel § So] reset interrupt § hi`ng Ctrl-‐Alt-‐Delete on a PC § Processes 10 University of Washington Synchronous ExcepJons ¢ Caused by events that occur as a result of execuJng an instrucJon: § Traps Inten:onal: transfer control to OS to perform some func:on § Examples: system calls, breakpoint traps, special instruc:ons § Returns control to “next” instruc:on § Faults § Uninten:onal but possibly recoverable § Examples: page faults (recoverable), segment protec:on faults (unrecoverable), integer divide-‐by-‐zero excep:ons (unrecoverable) § Either re-‐executes faul:ng (“current”) instruc:on or aborts § Aborts § Uninten:onal and unrecoverable § Examples: parity error, machine check § Aborts current program § Processes 11 University of Washington Trap Example: Opening File ¢
¢ User calls: open(filename, options) Func:on open executes system call instruc:on int
. . .
. . . User Process int pop int
%ebx OS excep/on open ﬁle returns ¢
¢ OS must ﬁnd or create ﬁle, get it ready for reading or wri:ng Returns integer ﬁle descriptor Processes 12 University of Washington Fault Example: Page Fault ¢
¢ User writes to memory loca:on That por:on (page) of user’s memory is currently on disk 80483b7: c7 05 10 9d 04 08 0d User Process movl ¢
¢ movl $0xd,0x8049d10 OS excep/on: page fault returns ¢ int a;
a = 13;
} Create page and load into memory Page handler must load page into physical memory Returns to faul:ng instruc:on: mov is executed again! Successful on second try Processes 13 University of Washington Fault Example: Invalid Memory Reference int a;
a = 13;
80483b7: c7 05 60 e3 04 08 0d User Process movl movl $0xd,0x804e360 OS excep/on: page fault detect invalid address signal process ¢
¢ Page handler detects invalid address Sends SIGSEGV signal to user process User process exits with “segmenta:on fault” Processes 14 University of Wash...
View Full Document
This document was uploaded on 04/04/2014.
- Fall '09