Module: Handling Exceptions

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/1/ / faculty of Electrical Engineering eindhoven university of technology Speeding it up Part 3: Out-Of-Order and SuperScalar execution dr.ir. A.C. Verschueren.
COMP 4211 Seminar Presentation Based On: Computer Architecture A Quantitative Approach by Hennessey and Patterson Presenter : Feri Danes.
Computer Organization and Architecture
CS 211: Computer Architecture Lecture 5 Instruction Level Parallelism and Its Dynamic Exploitation Instructor: M. Lancaster Corresponding to Hennessey.
CPE 731 Advanced Computer Architecture ILP: Part IV – Speculative Execution Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Sep 24, 2003 Topic: Pipelining -- Intermediate Concepts (Multicycle Operations;
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
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.
1 Lecture 8: Branch Prediction, Dynamic ILP Topics: static speculation and branch prediction (Sections )
Computer Organization and Architecture
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Computer Studies (AL) Memory Management Virtual Memory I.
Implementing Precise Interrupts in Pipelined Processors James E. Smith Andrew R.Pleszkun Presented By: Ravikumar Source:
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Spring 2003CSE P5481 Precise Interrupts Precise interrupts preserve the model that instructions execute in program-generated order, one at a time If an.
Implementing Precise Interrupts in Pipelined Processors James E. Smith Andrew R.Pleszkun Presented By: Shrikant G.
Computer Organization Instruction Set Architecture (ISA) Instruction Set Architecture (ISA), or simply Architecture, of a computer is the.
Computer System Architecture Interrupt and Precise Exception
1 Lecture: Out-of-order Processors Topics: a basic out-of-order processor with issue queue, register renaming, and reorder buffer.
Samira Khan University of Virginia Feb 9, 2016 COMPUTER ARCHITECTURE CS 6354 Precise Exception The content and concept of this course are adapted from.
CS203 – Advanced Computer Architecture ILP and Speculation.
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Computer Organization CS224
Operating Systems CMPSC 473
Mechanism: Limited Direct Execution
Lecture Topics: 11/1 Processes Process Management
Day 08 Processes.
Day 09 Processes.
Process Description and Control
CIS-550 Advanced Computer Architecture Lecture 10: Precise Exceptions
CS5100 Advanced Computer Architecture Hardware-Based Speculation
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Lecture: Static ILP Topics: predication, speculation (Sections C.5, 3.2)
Chapter 3: Windows7 Part 2.
Lecture 6: Advanced Pipelines
Lecture 8: ILP and Speculation Contd. Chapter 2, Sections 2. 6, 2
Computer-System Architecture
Module 2: Computer-System Structures
Chapter 3: Windows7 Part 2.
Adapted from the slides of Prof
15-740/ Computer Architecture Lecture 5: Precise Exceptions
Operating Systems.
Process Description and Control
BIC 10503: COMPUTER ARCHITECTURE
Exceptions Control Flow
Architectural Support for OS
Processes Hank Levy 1.
Operating Systems Lecture 3.
Adapted from the slides of Prof
Prof. Onur Mutlu Carnegie Mellon University Fall 2011, 9/30/2011
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Module 2: Computer-System Structures
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Computer Architecture
ECE 445 – Computer Organization
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Process.
Processes Hank Levy 1.
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Lecture 9: Dynamic ILP Topics: out-of-order processors
CMSC 611: Advanced Computer Architecture
Presentation transcript:

Module: Handling Exceptions ECE 4100/6100 Spring 2005 © Krishna V. Palem, Weng Fai Wong, and Sudhakar Yalamanchili, Georgia Institute of Technology (slides contributed by Prof. Weng Fai Wong were prepared while visiting, and employed by, Georgia Tech)

Reading for this Module General Section 3.1, pp. 179-180, Appendix A: A42-A44 History Buffer, Future File, Software recovery A-54-A-56 Re-order Buffer Section 3.7, pp. 232 Section 4.5, pp. 345-350 Spring 2005

Exceptions Unexpected situations encountered during the execution of an instruction Related terms Faults Unexpected situation caused by the execution of a particular instruction Traps Means by which the user can get OS attention Interrupts Asynchronous external hardware event Spring 2005

Process State When an exception occurs, the state of the interrupted process must be saved Exception handler is invoked May be inside or outside or both in and out of user space Spring 2005

Precise Exception An exception is precise if the following conditions are met: All the instructions preceding the instruction pointed to by the saved PC has been executed and have modified the process state correctly All instructions following the instruction pointed to by the saved PC have not yet been executed and have done no modification to the process state. If the exception is caused by the execution of an instruction in a program, then the saved PC points to that instruction. This instruction may or may not have been executed. This will depend on the definition of the architecture and the cause of the exception. Spring 2005

Sources of Precise Exceptions In I/O and timer exceptions, it is necessary to restart the execution of the instruction after the exception has been processed. Precise exceptions make this possible. Almost all processors today support virtual memory. In virtual memory, a page fault has to be serviced and this has to be precise so as to guarantee correctness. Precise exceptions is very useful in debugging as the exact (logical) situation of the exception can be reflected to the programmer. Spring 2005

Sources of Precise Exception In the IEEE standard for binary floating point, for example, certain exceptions are recoverable. For gradual underflow, for example, a floating point number may have gone into underflow. Then an exception handler is invoked to convert this floating point number into a denormalized number. Again, for ease of restart, precise exception is necessary. Unimplemented opcodes can be simulated in software if exceptions are precise. Privileged instructions will cause exceptions and these too should be precise. Spring 2005

Exceptions and Speculative Execution It is useful to distinguish between terminating and non-terminating exceptions The former typically correspond to program errors Exceptions should not be raised on instructions that will never execute For example control dependent speculative instructions For example, memory exceptions Spring 2005

Techniques to Support Precise Exceptions Reorder Buffer History buffer Future File Software Recovery Spring 2005

Reorder Buffer Additional info: Did the instruction generate an exception What sort of exception? Commit results if only there is no exception Else halt instruction processing, flush pipeline and bring in the handler Exceptions can be handled in commitment order Spring 2005

History Buffer The history buffer is a queue. Each entry contains: The program counter of the associated instruction; The number of the register in the register file to be overwritten by the associated instruction; The old value of that register; Any exception caused by the instruction; A flag to indicate the completion of the instruction Spring 2005

History Buffer Spring 2005

How It Works When an instruction is dispatched, an entry at the tail of the history buffer is allocated. The destination register number of the instruction, its current value and the PC value of the instruction are written into the allocated entry. The result of the instruction's execution is written directly into the register file. Spring 2005

How It Works Any exception in the execution of the instruction is noted in the associated history buffer entry. When a completed instruction reaches the head of the history buffer, and there is no exception, the entry is simply deleted. When an instruction having an exception reaches the head of the history buffer, instruction issue is immediately halted. Spring 2005

How It Works The processor then waits for all on-going computation to complete. The history buffer is scanned from head to tail and the old values of the registers in the history buffer entry are written back into the register file. Spring 2005

Future File A future file is duplicate set of registers Main register files maintained by reorder buffer No restrictions on how the future file is written Spring 2005

Future File Spring 2005

How It Works Upon dispatch, an instruction is allocated a reorder buffer entry at the tail of the reorder buffer. Operands are read from the future file. When an instruction completes, it will write into the reorder buffer and the future file. Spring 2005

How It Works When an instruction at the head of the reorder buffer completes without exception, it is committed to the architectural register file and its reorder buffer entry is simply deleted If an instruction at the head of the reorder buffer goes into exception, then instruction issue is halted and the pipelines are flushed and the content of the architectural register file is copied into the future file. Spring 2005

Software Recovery Exception handlers execute incomplete instructions to bring the machine to a known state Execution continues from the known state Example Spring 2005

How It Works The PCs of all instructions are available .. Instruction n-1 Instruction n Instruction causing the exception execution not completed execution completed The PCs of all instructions are available Goal: Restart at instruction n+1 Simulate the execution of instructions 1 through n Complex software implementation Complexity can be reduced by constraining the value of n Spring 2005

Concluding Remarks Imprecise vs. precise exceptions Precise exception handling benefits from architectural techniques for handling speculative execution For example, the reorder buffer Hardware and software can cooperate in the handling of exceptions Spring 2005

Study Guide What are the relative advantages and disadvantages of the techniques for handling precise exceptions? Find examples where it would be acceptable to support imprecise exceptions Track a speculative FP instruction that raised a FP exception through the ROB Build an example code sequence with conditionals Prediction indicates this instruction is executed The instruction raises an exception It reaches the head of the ROB before the branch condition is known For the preceding example, show the evolution of state of the history buffer and future file Spring 2005