240 likes | 324 Views
Computer Architecture. Lecture 10 EXCEPTIONS AND INTERRUPTS. Exceptions and Interrupts.
E N D
Computer Architecture Lecture 10 EXCEPTIONS AND INTERRUPTS
Exceptions and Interrupts • Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of some condition that changes the normal flow of execution. The condition is called an exception. Alternative concepts are interrupt, signal and event handling. • In general, current state will be saved in a predefined location and execution will switch to a predefined handler (subroutine/procedure). Depending on the situation, the handler may later resume the execution at the original location, using the saved information to restore the original state. For example, an exception which will usually be resumed is a page fault, while a division by zero usually cannot be resolved transparently. (Wikipedia)
Common Exceptions • I/O Device Request • Integer Arithmetic Overflow • FP Arithmetic Anomaly • Page Faults • Memory Protection Violation • Undefined Instruction • Power Failure • etc
Characterizing Exceptions • Synchronous vs. Asynchronous • User Requested (system calls)/Coerced (mouse click) • Maskable vs. Non-maskable • Within / Between Instructions • Resume-able/Terminate
Resumable • Shut pipeline by converting all instruction after the instruction causing exception to NOP • Save processor state • Call Handler • Resume State • Precise Exception ???
MIPS Interrupts • IF – Page Fault, MPV • ID – Undefined or Illegal Op Code • EX – Arithmetic • MEM – Same as IF • WB – None
Single Clock Cycle Single Cycle Computer (One Big Clock Cycle to Accommodate Longest Latency) IF ID EXE WB
EX IF ID WB IF IF ID ID EX EX WB WB Multiple Cycle Computers All Instruction Go through the Processing One-by-One
IF ID EX Mem WB Classic 5-Stage Integer Pipeline Almost 1 CPI except for LUD and Branch Hazards
A Multiple Cycle Pipeline Register File (Integer/FP) EX FP ADD IF ID Mem WB FP Multiply Register File (Integer/FP) Divide Register File
EX IF ID A 1 A 2 A 3 A 4 Mem WB M 1 M 2 .. M 7 Divide Multiple Cycle Floating Point Pipeline
EX IF ID A 1 A 2 A 3 A 4 Mem WB M 1 M 2 .. M 7 Divide Forwarding ALU/FP Instructions
Example 1 Without Forwarding With Forwarding
EXAMPLE 3 DIV Unit is not Pipelined. So second instruction waits in ID stage although it is independent.
Example 4 - Out Of Order Execution Note All Instructions Independent Out Of Order Completion
Example 5 Structural Hazard
Example 6 - WAW Reg Busy bit in Register File A particular processor – it waits in ID stage in case of WAW not in WB, Page A-54, Paragraph 2
Example 7 • L.D F4, 0(R2) • MUL.D F0,F4,F6 • ADD.D F2,F0,F8 • S.D F2,0(R2)
Example 8 - EXCEPTIONS • DIV.D F0,F1,F2 • ADD.D F10,F10,F8 • SUB.D F12,F12,F14
Data Hazards • RAW Hazard ADD.D F3, F1, F2 SUB.D F5, F6, F3 • WAW Hazard DIV.D F3, F1, F2 SUB.D F3, F6, F5 • WAR Hazard DIV.D F3, F1, F2 SUB.D F5, F6, F3 ADD.D F3, F6, F7