exceptional control flow
play

Exceptional Control Flow: Hardware support for reacting to the rest - PowerPoint PPT Presentation

Exceptional Control Flow: Hardware support for reacting to the rest of the world. Control Flow Processor: read instruction, execute it, go to next instruction, repeat Physical control flow Explicit changes: Jumps (conditional, unconditional)


  1. Exceptional Control Flow: Hardware support for reacting to the rest of the world.

  2. Control Flow Processor: read instruction, execute it, go to next instruction, repeat Physical control flow Explicit changes: Jumps (conditional, unconditional) <startup> Call, return inst 1 inst 2 time Exceptional changes: inst 3 user input … data arrives from disk or network inst n unexpected errors system calls <shutdown> 2

  3. Exceptions Synchronous: caused by instruction Traps: system calls Intentional: transfer control to OS to perform some function. OS runs at higher privilege level, so cannot call directly. Returns control to “next” instruction. Faults: unintentional, maybe recoverable page faults, protection faults, divide by zero Fix and re-execute faulting instruction or abort process. Aborts: unintentional, unrecoverable hardware failure detected Asynchronous (Interrupts): caused by external events incoming I/O activity, reset button, timers, signals

  4. Exceptions: hardware support for OS transfer control to OS in response to event What code should the OS run? User Code OS Kernel exception event exception processing by exception handler return or abort 4

  5. Interrupt Vector in memory special register holds base address code for exception handler 0 Exception code for Table exception handler 1 0 1 code for 2 exception handler 2 ... ... n-1 code for exception handler n-1 a jump table for exceptions… 5

  6. Open a file (trap/system call) User process calls: open(filename, options) open executes system call instruction int 0804d070 <__libc_open>: . . . 804d082: cd 80 int $0x80 804d084: 5b pop %ebx . . . User Code OS Kernel exception int pop open file returns 7

  7. Segmentation Fault int a[1000]; Write to invalid memory location. void bad () { a[5000] = 13; } 80483b7: c7 05 60 e3 04 08 0d movl $0xd,0x804e360 User Code OS Kernel exception: page fault movl detect invalid address signal process aborts process with SIGSEGV signal 8

  8. Page Fault int a[1000]; main () { a[500] = 13; Write to valid memory location } ... but contents currently on disk instead (more later: virtual memory) 80483b7: c7 05 10 9d 04 08 0d movl $0xd,0x8049d10 User Code OS Kernel exception: page fault movl Load page into memory reexecute same instruction 9

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend