Anda di halaman 1dari 15

COMPARISON BETWEEN

NTERRUPTS AND POLLIN

6/25/15

INTRODUCTION
An interrupt -signal to the microprocessor
from a device -attention.
An interrupt -event that stops the current
process -CPU -attend to the task needing
completion.
Polling-based program (non-interrupt driven)
continuously polls or tests whether data
-ready -received or transmitted.
6/25/15

INTERRUPTS
Whenever any device needs its service,
-notifies the microcontroller by sending
-interrupt signal.
The microcontroller interrupts whatever it is
doing and serves the device.
The program associated with the interrupt is
-Interrupt service routine (ISR) or interrupt
handler.

6/25/15

The Microcontroller -serve many devices (not


all at the same time)each device -attention of
the microcontroller -priority assigned to it.
No need to poll any more.

Can also ignore (mask) a device request


for service.
OS need not spend most of the processing
cycles. Easier to develop a multitasking OS.
6/25/15

TERRUPT SERVICE ROUTI


Interrupt service routine(ISR) is a software
routine that hardware invokes in response to an
interrupt.
When an interrupt is triggered either by
hardware or software interrupt, the processor
breaks away from the current task, moves the
instruction pointer to ISR , and then continues
operation.
6/25/15

SYNTAX
ISR(interrupt_vector_name )
{
// Code for interrupt handler
}

6/25/15

6/25/15

POLLING
The microcontroller continuously monitors
the status of a given device- status condition
is met, it performs the service.
After that, it moves on to monitor the next
device until each one is serviced.
Polling can monitor the status of several
devices and serve -as certain conditions are
met -not -efficient -use -microcontroller.
6/25/15

Cannot assign priority since it checks all devices


-round-robin fashion.
Cannot ignore (mask) a device request for service.
Wastes much of the microcontrollers time by
polling devices do not need service.
Multiple devices are monitored-aswitchstatement
needs to differentiate which I/O device requires
attention after the polling loop exits.

6/25/15

SYNTAX
While(1)
{
get device status
if(service required)
{
service_routine ;
}
normal_execution;
}

6/25/15

10

INTERRUPTS
Interrupts signal is sent
microprocessor

whenever

needs its service.

POLLING
to Microprocessor
continuously

device monitors the status of given device,


when the status condition is met, it
performs the service.

Priority based execution i.e. when Not priority based execution since it
its service is required by many checks all devices in a round robin
devices it provides service based on fashion.
priority.
Microcontroller can ignore a device Microcontroller
request for its service.

6/25/15

cannot

ignore

device request for its service.

11

Interrupt method do not waste Polling method wastes much of the


microcontroller's

time

since

it microcontrollers

time

by

polling

provides services to the required devices that do not need service.


devices.
ISR concentrates all peripheral Polling code is generally messy
code in one place.

and unstructured.

Processing time is less compared Processing time is more.


to polling method.
Interrupts

uses

microcontroller Polling uses lot of CPU horse

only when work is to be done.

power.

Interrupts give highly predictable Polled


servicing latencies.
6/25/15

code

leads

to

variable

latency in servicing peripherals.


12

PURPOSE OF
INTERRUPTS
Coordinating
I/O operations
Notifies the CPU that an input is ready or an
output can be changed

Timing
Periodic (clock-driven) interrupts remind the
CPU of the passage of time
Multi-tasking
Updating counters
Timing during interactive programs
6/25/15

13

Errors
Interrupts can notify error situations
Practical uses/examples
Change direction of a motor.
Auto wiper speed increased or decreased.
Pressing a pause button on a VCR

6/25/15

14

THANK YOU
6/25/15

15

Anda mungkin juga menyukai