Interrupt Routine of RTOS
Short Description
eqr...
Description
INTERRUPT ROUTINES IN AN RTOS ENVIRONMENT INTRODUCTION
Like Like stand-a stand-alon lonee system systems, s, embedd embedded ed applica applicatio tions ns runnin running g on top of real-tim real-timee operating systems (RTOSes) require Interrupt Serice Routines (ISRs) to !andle interrupts generated by e"ternal eents# $"ternal eents can be caused by %ust about anyt!ing, from an async!ronous c!aracter arrial on a &'RT to a periodic timer interrupt# ISRs !ae t!e responsibility of acknoledging t!e !ardare condition and proide t!e initial !andling of data sent or receied as required by t!e interrupt# 'n ISR often is responsible for proiding t!e RTOS RTOS it! information necessary necessa ry to proide serices to application t!reads# $"amples include moing data into a buffer for processing, adding an entry to a queue for processing, setting a alue to indicate t!at an eent !as occurred, and so on# Since application code e"ecution is interrupted (delayed) during t!e e"ecution of an ISR, most applications minimie t!e amount of code in t!e ISR and rely instead on non-ISR code (an application *T!read+ or *Task+) *Task+) to complete t!e processing# SYNOPSIS
RTOS IT$RR&T 'R./IT$.T&R$S
T$R0IOLO12
'R./IT$.T&R$
TOT'L S2ST$0 O3$R/$'4 .O0'RISO
.O.L&SIO R$5$R$.$S
RTOS INTERRUPT ARCHITECTURES
' fundam fundament ental al c!allen c!allenge ge in RTOS TOS design design is suppor supportin ting g async!r async!rono onous us access access to internal RTOS data structures by interrupt routines and RTOS serices# It cannot be alloed 6
t!at, !ile modifying a data structure, a serice or ISR gets interrupted and a different serice or ISR makes unrelated modifications to t!e same structure, leaing it in a c!anged state for t!e original code to (unknoingly) continue modifying# T!e results can be catastrop!ic# 'll RTOSes must address t!is c!allenge and preent multiple ISRs (or system calls) from modifying t!e same structure at t!e same time# T!is allos t!e !ig!est priority application code to be e"ecuted as quickly as possible, and delayed as little as possible, een in situations it! intense interrupt actiity#
T!ere are at least to approac!es, one used by
t!e ma%ority of RTOSes, and anot!er used by a fe# T!e more popular approac! is to briefly lockout interrupts !ile an ISR or system serice is modifying critical data structures inside t!e RTOS# T!is reliably preents any ot!er program from %umping in and making uncoordinated c!anges to t!e critical area being used by t!e e"ecuting code# 'not!er, less popular approac! is not to disable interrupts in system serice routines, but instead (by rule or conention) not allo any async!ronous access to critical data structures by ISRs or ot!er serice calls# Serice call access to critical data structures from an ISR is *deferred+ to a secondary routine e denote *ISR7,+ !ic! gets e"ecuted along it! application t!reads under sc!eduler control# T!is approac! also reliably preents interference it! t!e actions of an e"ecuting system serice call, by not alloing any t!reads or ISR7 routines, !ic! mig!t make system serice calls, to e"ecute until processing of critical data structures is completed# T!is approac! is called a *Segmented Interrupt 'rc!itecture,+ because it breaks up t!e processing required in response to an interrupt into multiple (usually 7) *segments+ e"ecuted at different priorities# In t!is paper, e e"amine t!e performance implications of eac! approac! on real-time system responsieness# TERMINOLOGY
T!e folloing is a list of symbols used to represent t!e processing performed in eac! type of RTOS interrupt arc!itecture8
Symbo
Meaning
l
..8
.onte"t .reate# .reate conte"t for ISR7# T!is typically inoles creating a stack frame and alerting t!e sc!eduler to sc!edule it ne"t# 7
.R8
.onte"t Restore# Restore conte"t of sc!eduled entity
.S8
.onte"t Sae# Saes t!e conte"t of t!e running t!read#
I48
Interrupt 4ispatc!er# 'pplicable in single interrupt ector arc!itectures like oer., 0IS, and 'R0# On arc!itectures like .old5ire, t!is item is done in !ardare#
ISR8
Interrupt Serice Routine# Traditional ISR, alloed to interact it! application t!reads t!roug! RTOS serices#
ISR68
Interrupt Serice Routine, art-6# Similar to traditional ISR, but not alloed to interact it! RTOS#
ISR78
Interrupt Serice Routine, art-7# Sc!eduled entity run in a t!read or super-t!read conte"t# 'lloed to interact it! RTOS serices and t!reads#
ITR'8
Interrupted T!read Running 'gain#
L8
Lockout# Interrupt lockout time#
S8
Sc!eduler# Sc!edule t!e most important t!read or ISR7#
T8
e T!read running#
68
Start of ISR processing#
78
$nd of ISR processing#
98
e t!read running : preemption case#
;8
Return to interrupted t!read#
View more...
Comments