Interrupts Interrupt the normal sequencing of the processor







- Slides: 7
Interrupts • Interrupt the normal sequencing of the processor. • An interrupt is a hardware signal that will stop the execution of the current program and give control to part of the operating system known as the interrupt handler. • Is a signal from some device or source seeking the attention of the processor Prepared by: Mazhar Javed 1
Why an interrupt may occur? • Hardware Interrupts • a printer may send an interrupt when has completed the printing of the last line of data. • a keyboard may send an interrupt when someone presses a key. • the timer in the processor may send an interrupt at regular intervals to perform certain functions. • a malfunctioning device may send an interrupt • Software Interrupts • some runtime errors (such as 'division by zero') will generate an interrupt. • some specific functions may be performed by sending an interrupt to the operating system. Prepared by: Mazhar Javed 2
Types of interrupts • Interrupt generated by running process to perform I/O, obtain more storage • I/O Interrupts: these are initiated by the I/O hardware and signal to the CPU that the status of a channel or device has changed. • Timer Interrupts : timer within the processor and allow the operation system to perform certain functions at regular intervals • Program check interrupts: these are caused by various types of errors such as division by Zero • Machine Check Interrupts : these are caused by malfunctioning hardware Prepared by: Mazhar Javed 3
Classes of Interrupts Prepared by: Mazhar Javed 4
Interrupt Handler • Program to service a particular I/O device • Generally part of the operating system • Suspends the normal sequence of execution • A small program called an interrupt service routine (ISR) or Interrupt handler. Prepared by: Mazhar Javed 5
Interrupt Service Routine )ISA Sequence or Algorithm of interrupt • Current fetch-execute cycle is completed. • The contents of the PC must be stored away safely so it can be restored after servicing the interrupt. • The contents of other registers used by the user program are stored safely for later restoration. • The source of the interrupt is identified. • Interrupts of a lower priority are disabled. • The PC is loaded with the start address of the relevant interrupt service routine. • The interrupt service routine is executed. • The saved values belonging to the user program for registers other than the PC are restored to the processor’s registers. • Interrupts are re-enabled. • The PC is restored to point to the next instruction to be fetched and executed in user program Prepared by: Mazhar Javed 6
Vector Interrupt system : • Polling • the interrupting device supplies a number which is added to a fixed number. • The base address plus offset is the address of a vector. Prepared by: Mazhar Javed 7