19
Interrupts By: Mr. Irfanullah C/NO: 14 MS (Computer Science) University Of Peshawar

interrupts-090527014956-phpapp01

Embed Size (px)

Citation preview

Page 1: interrupts-090527014956-phpapp01

Interrupts

By:

Mr. Irfanullah

C/NO: 14

MS (Computer Science)

University Of Peshawar

Page 2: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

2

In This Demonstration

What Are Interrupts?

Why Interrupts?

Instruction Cycle And Interrupts

Difference b/w Interrupts and Exceptions

Classes Of Interrupts

How They Are Handled?

I/O Communication Techniques

Queries and Suggestions

Page 3: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

3

What Are Interrupts?

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.

A way to improve processor utilization.

Page 4: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

4

Need For Interrupts?

The OS is a reactive program

When you give some input

It will perform computations

Produces output BUT

Meanwhile you can interact with the system by

interrupting the running process or

You can stop and start another process.

This reactive ness is due to interrupts

Modern Operating Systems Are Interrupt driven

Page 5: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

5

Instruction Cycle And Interrupts

Without Interrupts

Two steps ( cycles)

Instruction Fetch

Instruction Execute

Page 6: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

6

Instruction Cycle And Interrupts (Continued)

State Diagram

( Without Interrupts)

Page 7: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

7

Instruction Cycle And Interrupts (Continued)

With Interrupts

Three steps ( cycles)

Instruction Fetch

Instruction Execute

Check Interrupt

Page 8: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

8

Instruction Cycle And Interrupts (Continued)

State Diagram ( With

Interrupts)

Page 9: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

9

Difference Interrupts and Exceptions

Two main types of events: interrupts and

exceptions

Exceptions are caused by software executing

instructions

e.g., a page fault, or an attempted write to a read-

only page

an expected exception is a “trap”, unexpected is a

“fault”

Interrupts are caused by hardware devices

e.g., device finishes I/O

e.g., timer fires

Page 10: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

10

Classes Of Interrupts

Program 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.

Timer Generated by a timer within the processor. This allows the

operating system to perform certain functions on a regular basis.

I/O Generated by an I/O controller, to signal normal completion

of an operation or to signal a variety of error conditions.

Hardware failure Generated by a failure, such as power failure or memory parity error.

Page 11: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

11

How Interrupts Are Handled?

Different routines handle different interrupts –called Interrupt Service Routines (ISR).

When CPU is interrupted

It stops what it was doing, and context is saved.

A generic routine called Interrupt Handling Routine (IHR) is run which

Examines the nature of interrupt

Calls the corresponding Interrupt Service Routine (ISR) -- stored in lower part of memory.

After servicing the interrupt, the saved address is loaded again to PC to resume the process again.

Page 12: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

12

How Interrupts Are Handled? (Continued)

Page 13: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

13

How Interrupts Are Handled? (Continued)

Interrupt

Processing

Page 14: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

14

I/O COMMUNICATION

TECHNIQUES

Three techniques are possible for I/O operations

Programmed I/O

Interrupt-driven I/O

Direct memory access (DMA)

Page 15: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

15

Programmed I/O

CPU while executing a

program encounters an I/O

instruction

CPU issues I/O command to

I/O module

I/O module performs the

requested action & set status

registers

CPU is responsible to check

status registers periodically to

see if I/O operation is

complete. SO

No Interrupt to alert the

processor

Page 16: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

16

Interrupt-Driven I/O

Similar to direct I/O but

processor not required

to poll device.

I/O module will interrupt

CPU for data exchange

when ready

Page 17: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

17

Direct Memory Access (DMA)

I/O exchanges occur directly with memory Requires DMA module on system

bus

Capable of mimicking CPU and taking over control of system from CPU

DMA will use bus when Processor does not require it

OR

Must force processor to suspend operation temporarily– called cycle stealing

An interrupt is sent when the task is complete

The processor is only involved at the beginning and end of the transfer

Page 18: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

18

Another Look at I/O

Synchronous (Programmed I/O) - control

returns to user program only upon I/O

completion.

Idle CPU until the next interrupt

wait loop (contention for memory access).

Asynchronous (Interrupt driven I/O) - control

returns to user program before I/O completion.

System call – request to the operating system to

allow user to wait for I/O completion.

Device-status table contains entry for each I/O

device indicating its type, address, and state.

Page 19: interrupts-090527014956-phpapp01

Interrupts By: Irfanullah University Of Peshawar,

Pakistan

19

Thanks

Queries

AND

Suggestions