You are on page 1of 19

1.

INTERRUPT ROUTINES IN
RTOS

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 1


Raj Kamal, Publs.: McGraw-Hill Education
What is Interrupt
A hardware signal that initiates an event.
Upon receipt of an interrupt the processor
 Completes the instruction being executed
 Save the program counter (so as to return to the
same execution point)
 Loads the program counter with the location of
the interrupt handler code
 Executes the interrupt handler
In practice,real time systems can handle several
interrupts in priority fashions
 Interrupts can be enabled or disabled
 Highest priority interrupts serviced first.
ISRs in RTOSes
 ISRs have the higher priorities over the RTOS
functions and the tasks.
 An ISR should not wait for a semaphore, mailbox
message or queue message
 An ISR should not also wait for mutex else it has
to wait for other critical section code to finish
before the critical codes in the ISR can run.
 Only the IPC accept function for these events
(semaphore, mailbox, queue) can be used, not the
post function
2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 3
Raj Kamal, Publs.: McGraw-Hill Education
RTOSes
 Three alternative ways systems to respond
to hardware source calls from the
interrupts

 Direct call to ISR by an Interrupting


Source.
 Direct call to RTOS by an Interrupting

Source and Temperary Suspension of


Scheduled task.
 Direct call to RTOS by an Interrupting

Source and scheduling of Tasks as well as


ISRs by the RajRTOS.
2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 4
Kamal, Publs.: McGraw-Hill Education
2. Direct Call to an ISR by an
Interrupting Source and ISR sending
an ISR enter
message to OS

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 5


Raj Kamal, Publs.: McGraw-Hill Education
Direct Call to an ISR

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 6


Raj Kamal, Publs.: McGraw-Hill Education
Direct Call to an ISR and ISR Enter
message
 On an interrupt, the process running
at the CPU is interrupted
 ISR corresponding to that source
starts executing.
 A hardware source calls an ISR directly.

The ISR just sends an ISR enter
message to the RTOS. ISR enter message
is to inform the RTOS that an ISR has
taken control of the CPU
2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 7
Raj Kamal, Publs.: McGraw-Hill Education
ISR IPC messages and Exit message
 ISR code can send into a mailbox or
message queue but the task waiting for
a mailbox or message queue does not
start before the return from the ISR
 When ISR finishes, it send s Exit
message to OS

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 8


Raj Kamal, Publs.: McGraw-Hill Education
ISR IPC messages and Exit message
 On return from ISR by retrieving saved
context, The RTOS later on returns to
the interrupted process (task) or
reschedules the processes (tasks).

RTOS action depends on the
event- messages, whether the task
waiting for the event message from
the ISR is a task of higher priority
than the interrupted task on the
interrupt
2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 9
Raj Kamal, Publs.: McGraw-Hill Education
3. RTOS interrupting first on an interrupt,
then RTOS calling the corresponding ISR

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 10


Raj Kamal, Publs.: McGraw-Hill Education
RTOS first interrupting on an interrupt

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 11


Raj Kamal, Publs.: McGraw-Hill Education
RTOS interrupting on an interrupt
 On interrupt of a task, say, k-th task, the
RTOS first gets itself the hardware source
call and initiates the corresponding ISR
after saving the present processor status
(or context)
 Then the ISR during execution then can
post one or more outputs for the events
and messages into the mailboxes or
queues.
2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 12
Raj Kamal, Publs.: McGraw-Hill Education
RTOS first interrupting on an interrupt
 The ISR must be short and it must
simply puts post the messages for
another task.
 This task runs the remaining

codes whenever it is scheduled.


 RTOS schedules only the tasks (processes)

and switches the contexts between the


tasks only.
 ISR executes only during a
2015temporary suspension
Chapter-10 L9: "Embedded of a
Systems - Architecture, task.
Programming and Design" , 13
Raj Kamal, Publs.: McGraw-Hill Education
4. RTOS first interrupting on interrupt,
then RTOS calling the corresponding ISR,
the ISR sending messages to priority queue
of Interrupt Service threads by
Temporary Suspension of a scheduled
Task

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 14


Raj Kamal, Publs.: McGraw-Hill Education
Direct call to RTOS by an Interrupting
Source and scheduling of Tasks as well as
ISRs by the RTOS

2015 Chapter-10 L9: "Embedded Systems - Architecture, Programming and Design" , 15


Raj Kamal, Publs.: McGraw-Hill Education
 Direct call to RTOS by an Interrupting
Source and scheduling of Tasks as well
as ISRs by the RTOS
1.TheRTOS intercepts and executes the task needed on return from the
ISR without any message for initiating the task from ISR.

2. There are three i-th ISR,RTOS and j-th task in three memory blocks.

3. An i-th interrupt source causes the RTOS to call the i-th ISR and
block the j-th task. ISR_i executes after RTOS switches the context.

4. The routine does not send any messages to the RTOS for initiating the
i-th task.

5. The routine sends the IPCs for the needed parameters for a task.

6. The Parameters are stored at the memory allotted for the RTOS
inputs.
.
7 The RTOS now calls on return and restoration of the context and
switches the context to run later the codes needed for the jth or any other
task.

8. The ISR need not be short and simply generates and saves as the IPCS
the input parameters

9. It is the task that runs the codes whenever called.

10. RTOS schedules not only the tasks but also the ISRs and switches the
contexts between the tasks as well as the ISRs.
Summary
1. An ISR serving directly or merely informing the
RTOS.

2. Kernel intercepting the call and calling the


corresponding ISR and task.
* RTOS Kernel schedules only the tasks and ISR
executes only turing temporary suspension of tasks.

3. Kernel calling the ISR for the parameters by


context switch and later executing the task
corresponding to the source when the RTOS kernel
switches back the context when the task is
scheduled.
RTOS Schedules not only task but also ISR.
RTOS TASK SCHEDULING
MODELS,INTERRUPT LATENCY AND
RESPONSE TIMES OF THE TASKS AS
PERFORMANCE METRICS.

The three common model stratergies that a


scheduler may adopt are:

Control flow strategy


Data Flow Strategy
Control-Data Flow Strategy

You might also like