Multitasking Environment with Lowest Interrupt Latency
Offered by HW-RTOS
3
/
8
R70WP0003EJ0100 September, 2018
which is currently awaiting a flag. So, the Set Flag
API is invoked. Task 1 meets the conditions required
for release from the Wait state, and then moves to
the Ready state. The ISR no longer has any work to
do and terminates itself. Then, since Task 1 has a
higher priority level than the previously running Task
2, Task 1 is run. Accordingly, while Task 1 is running,
if a new interrupt occurs, the start of the
corresponding ISR is not delayed. t Thus, by handing
ISR processing over to a task, the only thing the ISR
needs to do is invoke an API, and all the other
processing can be left to the task.
In addition to Set Flag, other APIs used for this
goal include Semaphore Release and Wait Release.
Here we are simply using the ISR to invoke an
API, but of course it's also acceptable to execute
processes with high real time performance within the
ISR. It's optimal, though, to execute only the most
urgent processes in ISR, and execute all others with
Task 1.
As described above, skillful use of the RTOS in
interrupt handling allows timely running of high
priority processes, as well as interrupt disabled
periods made as short as possible.
2.2. OS managed Interrupt and Non-OS
managed Interrupt
There are interrupts managed by the OS and
those managed outside the OS. As discussed in 2.1,
the interrupt-activated handler itself is an interrupt
managed by the RTOS. This interrupt-activated
handler is called an OS-managed interrupt handler
(in this text, we call this OS-managed interrupt
handler “ISR”, or “Interrupt Service Routine”). The
priority level relationship between the RTOS, the ISR,
and tasks is shown in Figure 3.
When we say that the RTOS manages an
interrupt, it means that the OS activates the ISR.
Namely, when an interrupt occurs, the RTOS
activates the ISR corresponding to that interrupt. As
you can see from the figure, tasks have the lowest
priority level, then the ISR, and next comes the
RTOS. Since, as the figure shows, the RTOS is higher
priority than the ISR, if an interrupt occurs while the
RTOS is in the middle of a process, ISR activation is
delayed. As a result, the RTOS creates overhead
between the occurrence of an interrupt and ISR
activation. Generally, since RTOS processes tend to
be critical ones, they are run with interrupts disabled.
It's vital to be aware of these delays in ISR activation
by OS managed interrupts as described above.
Now we'll discuss non-OS managed interrupts .
The handler activated by non-OS managed interrupts
is called a non-OS managed interrupt handler. As you
can see in Figure 3, non-OS managed interrupt
handlers are even higher priority than the RTOS
process. As a result, even if the RTOS is in the
middle of a process, that process can be interrupted
and the handler activated immediately. Since the
software has absolutely no role in this activation, the
latency up until the handler is activated is the
interrupt latency as defined by the CPU. This non-OS
managed interrupt handler is often used in
applications which simply cannot allow much RTOS
overhead, such as high-speed servo motor control.
Another difference between the ISR and non-OS
managed interrupt handler is whether or not an API
can be invoked during the handler process. Since the
ISR is run under RTOS management, it's possible to
invoke an API. However, since a non-OS managed