Interrupt Routine of RTOS

Share Embed Donate


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 Serice Routines (ISRs) to !andle interrupts generated by e"ternal eents# $"ternal eents can be caused by %ust about anyt!ing, from an async!ronous c!aracter arrial on a &'RT to a periodic timer interrupt# ISRs !ae t!e responsibility of acknoledging t!e !ardare condition and proide t!e initial !andling of  data sent or receied as required by t!e interrupt# 'n ISR often is responsible for proiding t!e RTOS RTOS it! information necessary necessa ry to proide serices to application t!reads# $"amples include moing data into a buffer for processing, adding an entry to a queue for processing, setting a alue to indicate t!at an eent !as occurred, and so on# Since application code e"ecution is interrupted (delayed) during t!e e"ecution of an ISR, most applications minimie 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 IT$RR&T 'R./IT$.T&R$S



T$R0IOLO12



'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 serices# It cannot be alloed 6

t!at, !ile modifying a data structure, a serice or ISR gets interrupted and a different serice or ISR makes unrelated modifications to t!e same structure, leaing it in a c!anged state for  t!e original code to (unknoingly) continue modifying# T!e results can be catastrop!ic# 'll RTOSes must address t!is c!allenge and preent multiple ISRs (or system calls) from modifying t!e same structure at t!e same time# T!is allos t!e !ig!est priority application code to be e"ecuted as quickly as possible, and delayed as little as possible, een in situations it! intense interrupt actiity#

T!ere are at least to 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 serice is modifying critical data structures inside t!e RTOS# T!is reliably preents 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 serice routines,  but instead (by rule or conention) not allo any async!ronous access to critical data structures by ISRs or ot!er serice calls# Serice 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 preents interference it! t!e actions of an e"ecuting system serice call, by not alloing any t!reads or ISR7 routines, !ic! mig!t make system serice 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 responsieness# TERMINOLOGY

T!e folloing 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 inoles 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 Sae# Saes t!e conte"t of t!e running t!read#

I48

Interrupt 4ispatc!er# 'pplicable in single interrupt ector arc!itectures like oer., 0IS, and 'R0# On arc!itectures like .old5ire, t!is item is done in !ardare#

ISR8

Interrupt Serice Routine# Traditional ISR, alloed to interact it! application t!reads t!roug! RTOS serices#

ISR68

Interrupt Serice Routine, art-6# Similar to traditional ISR, but not alloed to interact it! RTOS#

ISR78

Interrupt Serice Routine, art-7# Sc!eduled entity run in a t!read or super-t!read conte"t# 'lloed to interact it! RTOS serices 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

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF