Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

What are interrupts? Why We Need them? Different I/O techniqes and many more

Published in: Education, Business, Technology


  1. 1. Interrupts By: Mr. Irfanullah C/NO: 14 MS (Computer Science) University Of Peshawar
  2. 2. In This Demonstration <ul><li>What Are Interrupts? </li></ul><ul><li>Why Interrupts? </li></ul><ul><li>Instruction Cycle And Interrupts </li></ul><ul><li>Difference b/w Interrupts and Exceptions </li></ul><ul><li>Classes Of Interrupts </li></ul><ul><li>How They Are Handled? </li></ul><ul><li>I/O Communication Techniques </li></ul><ul><li>Queries and Suggestions </li></ul>
  3. 3. What Are Interrupts? <ul><li>A Suspension of a process such as the execution of a computer program, caused by an event external to that process, and performed in such a way that the process can be resumed. </li></ul><ul><li>A way to improve processor utilization. </li></ul>
  4. 4. Need For Interrupts? <ul><li>The OS is a reactive program </li></ul><ul><ul><li>When you give some input </li></ul></ul><ul><ul><li>It will perform computations </li></ul></ul><ul><ul><li>Produces output BUT </li></ul></ul><ul><ul><li>Meanwhile you can interact with the system by interrupting the running process or </li></ul></ul><ul><ul><li>You can stop and start another process. </li></ul></ul><ul><li>This reactive ness is due to interrupts </li></ul><ul><li>Modern Operating Systems Are Interrupt driven </li></ul>
  5. 5. Instruction Cycle And Interrupts <ul><li>Without Interrupts </li></ul><ul><ul><li>Two steps ( cycles) </li></ul></ul><ul><ul><ul><li>Instruction Fetch </li></ul></ul></ul><ul><ul><ul><li>Instruction Execute </li></ul></ul></ul>
  6. 6. Instruction Cycle And Interrupts (Continued) <ul><li>State Diagram </li></ul><ul><li>( Without Interrupts) </li></ul>
  7. 7. Instruction Cycle And Interrupts (Continued) <ul><li>With Interrupts </li></ul><ul><ul><li>Three steps ( cycles) </li></ul></ul><ul><ul><ul><li>Instruction Fetch </li></ul></ul></ul><ul><ul><ul><li>Instruction Execute </li></ul></ul></ul><ul><ul><ul><li>Check Interrupt </li></ul></ul></ul>
  8. 8. Instruction Cycle And Interrupts (Continued) <ul><li>State Diagram ( With Interrupts) </li></ul>
  9. 9. Difference Interrupts and Exceptions <ul><li>Two main types of events: i nterrupts and exceptions </li></ul><ul><ul><li>Exceptions are caused by software executing instructions </li></ul></ul><ul><ul><ul><li>e.g., a page fault, or an attempted write to a read-only page </li></ul></ul></ul><ul><ul><ul><li>an expected exception is a “trap”, unexpected is a “fault” </li></ul></ul></ul><ul><ul><li>Interrupts are caused by hardware devices </li></ul></ul><ul><ul><ul><li>e.g., device finishes I/O </li></ul></ul></ul><ul><ul><ul><li>e.g., timer fires </li></ul></ul></ul>
  10. 10. Classes Of Interrupts <ul><li>Program </li></ul><ul><ul><li>Generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow , division by zero , attempt to execute an illegal machine instruction etc. </li></ul></ul><ul><li>Timer </li></ul><ul><ul><li>Generated by a timer within the processor. This allows the operating system to perform certain functions on a regular basis. </li></ul></ul><ul><li>I/O </li></ul><ul><ul><li>Generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions. </li></ul></ul><ul><li>Hardware failure </li></ul><ul><ul><li>Generated by a failure, such as power failure or memory parity error. </li></ul></ul>
  11. 11. How Interrupts Are Handled? <ul><li>Different routines handle different interrupts –called Interrupt Service Routines (ISR). </li></ul><ul><li>When CPU is interrupted </li></ul><ul><ul><li>It stops what it was doing, and context is saved. </li></ul></ul><ul><ul><li>A generic routine called Interrupt Handling Routine (IHR) is run which </li></ul></ul><ul><ul><ul><li>Examines the nature of interrupt </li></ul></ul></ul><ul><ul><ul><li>Calls the corresponding Interrupt Service Routine (ISR) -- stored in lower part of memory. </li></ul></ul></ul><ul><li>After servicing the interrupt, the saved address is loaded again to PC to resume the process again. </li></ul>
  12. 12. How Interrupts Are Handled? (Continued)
  13. 13. How Interrupts Are Handled? (Continued) <ul><li>Interrupt </li></ul><ul><li>Processing </li></ul>
  14. 14. I/O COMMUNICATION TECHNIQUES <ul><li>Three techniques are possible for I/O operations </li></ul><ul><ul><li>Programmed I/O </li></ul></ul><ul><ul><li>Interrupt-driven I/O </li></ul></ul><ul><ul><li>Direct memory access (DMA) </li></ul></ul>
  15. 15. Programmed I/O <ul><li>CPU while executing a program encounters an I/O instruction </li></ul><ul><li>CPU issues I/O command to I/O module </li></ul><ul><li>I/O module performs the requested action & set status registers </li></ul><ul><li>CPU is responsible to check status registers periodically to see if I/O operation is complete. SO </li></ul><ul><li>No Interrupt to alert the processor </li></ul>
  16. 16. Interrupt-Driven I/O <ul><li>Similar to direct I/O but </li></ul><ul><li>processor not required to poll device. </li></ul><ul><li>I/O module will interrupt CPU for data exchange when ready </li></ul>
  17. 17. Direct Memory Access (DMA) <ul><li>I/O exchanges occur directly with memory </li></ul><ul><ul><li>Requires DMA module on system bus </li></ul></ul><ul><ul><li>Capable of mimicking CPU and taking over control of system from CPU </li></ul></ul><ul><ul><li>DMA will use bus when </li></ul></ul><ul><ul><ul><li>Processor does not require it OR </li></ul></ul></ul><ul><ul><ul><li>Must force processor to suspend operation temporarily– called cycle stealing </li></ul></ul></ul><ul><li>An interrupt is sent when the task is complete </li></ul><ul><li>The processor is only involved at the beginning and end of the transfer </li></ul>
  18. 18. Another Look at I/O <ul><li>Synchronous (Programmed I/O) - control returns to user program only upon I/O completion. </li></ul><ul><ul><li>Idle CPU until the next interrupt </li></ul></ul><ul><ul><li>wait loop (contention for memory access). </li></ul></ul><ul><li>Asynchronous (Interrupt driven I/O) - control returns to user program before I/O completion. </li></ul><ul><ul><li>System call – request to the operating system to allow user to wait for I/O completion. </li></ul></ul><ul><ul><li>Device-status table contains entry for each I/O device indicating its type, address, and state. </li></ul></ul>
  19. 19. Thanks <ul><li>Queries </li></ul><ul><li>AND </li></ul><ul><li>Suggestions </li></ul>