Es CH 1 Part 3
Es CH 1 Part 3
Serial
Port
CPU
TTTTT
Network
Interface Interrup
request pins.
TTTT
This signal tells the microprocessor
that the network chip needs service.
19-10 207
DAMSjaya,est d(I4I, AUKI (A)
Interrupt routines are subroutines that do whatever needs to be
done when the interrupt signal occurs
An interrupt routine is also called as an interrufpt handler o r an
Disabling Interrupts
Almost every system allows to disable interrupts.
most 1/0 chips allow program to tell them not to interrupt, even if
they need the microprocessor's attention by stopping the interrupt
signal at the source.
system that depends upon interrupt routines which is usually all processing in
an embedded system--will grind to a halt.
What happens ifI disable internupts when they are already. disabled or enable interupts
when they are already enabled? Nothing.
Are intemupts enabled or disabled when the microprocessor first starts up? Disabled.
Can I write my interrupt usually. Most com1pilers used for
routines in C? Ys,
embed ded-systems code recognize a nonstandard keyword that allows you to
tell the compiler that a particular function is an interrupt routine. For example:
1 Templ
1nt iTempo. :
while ( TRUE
i Tempo 1Temperatures[0J:
i Femp1 Temperatures[1]:
-
f (1Temp0 ! 1 Temp1)
I! Set off howl ing alarm;
Problem - It sets off the alarm even though the two measured temperatures are same.
wh1le (TRUE)
1f (1Temp0 ! 1Temp1)
!!Set off howling alarm;
16
12-10200) DAM.Sowjanya,Irgt. d(S&T, AUKI(A)
Atomic and Critical Section
Atomic -A part of a program which cannot be interrupted.
Shared-data problem arises when an interrupt routine and the task
code share data, and the task code uses the shared data in a way that is
not atomic. Disable interrupts around lines of task code that use shared
data, that collection of lines becomes atomic, and problem is solved.
To solve its shared-data problem, the nuclear reactor program need only
disable the interrupt that reads temperatures. If other interrupts change
other data (time of day, water pressures, steam pressures) while the task
code is working with the temperatures, that will cause no problem.
Critical section -A set of instructions that must be atomic for the
system to work properly.
12-10 2072 IAMSjzya,Ipt d(S8,AUXI (A)
Figure 4.9 Interrupts with a Timer
+1 Seconds:
if (iSeconds 60)
iSeconds 0 :
++iNinutes:
if (iM nutes >- 60)
1Minutes-0 :
+ Hours:
1f (1Hours >- 24)
Hours-0;