CSC 2405 Computer Systems II Exceptions Mini-Lecture Traps & Interrupts.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Carnegie Mellon 1 Exceptional Control Flow: Exceptions and Processes /18-243: Introduction to Computer Systems 13 th Lecture, June 15, 2011 Instructors:
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
University of Washington Today Midterm grades posted  76. HW 3 due Lab 4 fun! 1.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Exceptional Control Flow Part I September 22, 2008 Topics Exceptions Process context switches Creating and destroying processes class11.ppt ,
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Exceptional Control Flow Part I Topics Exceptions Process context switches Creating and destroying processes class14.ppt CS 123.
Exceptional Control Flow Part I Topics Exceptions Process context switches Creating and destroying processes.
Introduction to Interrupts
Exceptions, Interrupts & Traps
COMPUTER SYSTEMS An Integrated Approach to Architecture and Operating Systems Chapter 4 Processor Implementation ©Copyright 2008 Umakishore Ramachandran.
Intel IA32 OS Support -Refresh
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Fabián E. Bustamante, Spring 2007 Exceptional Control Flow Part I Today Exceptions Process context switches Creating and destroying processes Next time.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Exceptional Control Flow Part I March 4, 2004 Topics Exceptions Process context switches Creating and destroying processes class16.ppt “The course.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 COMPUTER ARCHITECTURE (for Erasmus students) Assoc.Prof. Stasys Maciulevičius Computer Dept.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
מנהלות. שעות קבלה סיוון סבתו -) יעודכן בקרוב באתר ( רוס 60 עומר לב - רביעי 16:00-17:00 רוס 25 ) קומה 1-( –בתאום מראש במייל הקורס !
University of Amsterdam Computer Systems – Processes Arnoud Visser 1 Computer Systems Processes.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Exceptional Control Flow Part I Topics Exceptions Process context switches Creating and destroying processes class16.ppt.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
University of Washington Exceptional Control Flow The Hardware/Software Interface CSE351 Winter 2013.
Exceptional Control Flow I March 12, 2002
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Carnegie Mellon 1 CMSC os1: OS and Exceptions Chapter 8.1 Instructors: Haryadi Gunawi Henry Hoffmann Matthew Wachs.
Computer System Structures Interrupts
Exceptional Control Flow
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and exceptions
Processor States normal exception
MICROPROCESSOR BASED SYSTEM DESIGN
Operating Systems CMPSC 473
Exceptional Control Flow & Processes
Exceptional Control Flow
Microprocessor Systems Design I
Exceptional Control Flow
Anton Burtsev February, 2017
Exceptional Control Flow
Overview of today’s lecture
Exceptional Control Flow Part I
Exceptional Control Flow
os1: OS and Exceptions Chapter 8.1
Exceptional Control Flow: System Calls, Page Faults etc.
GEOMATIKA UNIVERSITY COLLEGE CHAPTER 2 OPERATING SYSTEM PRINCIPLES
Exceptional Control Flow I
Exceptional Control Flow Part I
Exceptions Control Flow
Architectural Support for OS
Exceptions and Processes
CS201 - Lecture 17 Exceptions
Architectural Support for OS
Exceptional Control Flow & Processes October 2, 2008
Interrupts and exceptions
Interrupts and System Calls
Presentation transcript:

CSC 2405 Computer Systems II Exceptions Mini-Lecture Traps & Interrupts

2 2 here is an analogy... Teacher OS is each student I/O device is Consider the inefficiency of OS polling.

3 3 Because polling is so inefficient, instead of OS device 1 ready? device 2 ready? device n ready?... ask

4 4 Turn the situation upside down OS device 1device 2device n... ready!

5 5

6 6 the analogy continues... Teacher (tries to) answer question OS handles interrupt is student with a question raises hand device ready sends interrupt request is

7 7 Types of Exceptions 1. traps 2. interrupts

8 Chapter 8 Exceptions An exception is a transfer of control to the OS in response to some event (i.e., change in processor state) User ProcessOS exception exception processing by exception handler exception return (optional) event current next

9 Chapter 8 Example Exceptions Divide by zero – n / 0 Segmentation fault – program tries to access memory it doesn’t “own” Abnormal termination – abort Overflow – usually mult or add Bad or illegal instruction – no such function Termination request – program requests to exit

10 Chapter 8 Interrupt Vectors – Each type of event has a unique exception number k – Index into jump table (a.k.a., interrupt vector) – Jump table entry k points to a function (exception handler). – Handler k is called each time exception k occurs. interrupt vector n-1 code for exception handler 0 code for exception handler 0 code for exception handler 1 code for exception handler 1 code for exception handler 2 code for exception handler 2 code for exception handler n-1 code for exception handler n-1... Exception numbers

11 Chapter 8 Asynchronous Exceptions (Interrupts) Caused by events external to the processor – Indicated by setting the processor’s interrupt pin – handler returns to “next” instruction. Examples: – I/O interrupts hitting ctl-c at the keyboard arrival of a packet from a network arrival of a data sector from a disk – Hard reset interrupt hitting the reset button – Soft reset interrupt hitting ctl-alt-delete on a PC

12 Chapter 8 Trap Example User ProcessOS exception Open file return int pop Opening a File – User calls open(filename, options) Function open executes system call instruction int – OS must find or create file, get it ready for reading or writing – Returns integer file descriptor 0804d070 : d082:cd 80 int $0x80 804d084:5b pop %ebx...

13 Chapter 8 Fault Example #1 User ProcessOS page fault Create page and load into memory return event movl Memory Reference – User writes to memory location – That portion (page) of user’s memory is currently on disk – Page handler must load page into physical memory – Returns to faulting instruction – Successful on second try int a[1000]; main () { a[500] = 13; } 80483b7:c d d movl $0xd,0x8049d10

14 Chapter 8 Fault Example #2 User ProcessOS page fault Detect invalid address event movl Memory Reference – User writes to memory location – Address is not valid – Page handler detects invalid address – Sends SIGSEG signal to user process – User process exits with “segmentation fault” int a[1000]; main () { a[5000] = 13; } 80483b7:c e d movl $0xd,0x804e360 Signal process

15 Chapter 8 Synchronous Exceptions Caused by events that occur as a result of executing an instruction: – Traps Intentional Examples: system calls, breakpoint traps, special instructions Returns control to “next” instruction – Faults Unintentional but possibly recoverable Examples: page faults (recoverable), protection faults (unrecoverable). Either re-executes faulting (“current”) instruction or aborts. – Aborts unintentional and unrecoverable Examples: parity error, machine check. Aborts current program