User`s guide

Overview of Thread Scheduling
4-4
4.1.2 Choosing Which Types of Threads to Use
The type and priority level you choose for each thread in an application
program has an impact on whether the threads are scheduled on time and
executed correctly. The Configuration Tool makes it easy to change a thread
from one type to another.
Here are some rules for deciding which type of object to use for each task to
be performed by a program:
SWI or TSK versus HWI. Perform only critical processing within
hardware interrupt service routines. HWIs should be considered for
processing hardware interrupts (IRQs) with deadlines down to the
5-microsecond range, especially when data may be overwritten if the
deadline is not met. Software interrupts or tasks should be considered for
events with longer deadlines—around 100 microseconds or more. Your
HWI functions should post software interrupts or tasks to perform lower-
priority processing. Using lower-priority threads minimizes the length of
time interrupts are disabled (interrupt latency), allowing other hardware
interrupts to occur.
SWI versus TSK. Use software interrupts if functions have relatively
simple interdependencies and data sharing requirements. Use tasks if the
requirements are more complex. While higher-priority threads can
preempt lower priority threads, only tasks can be suspended to wait for
another event, such as resource availability. Tasks also have more options
than SWIs when using shared data. All input needed by a software
interrupt’s function should be ready when the program posts the SWI. The
SWI object’s mailbox structure provides a way to determine when
resources are available. SWIs are more memory efficient because they all
run from a single stack.
IDL. Create background functions to perform noncritical housekeeping
tasks when no other processing is necessary. IDL functions do not
typically have hard deadlines. Instead, they run whenever the system has
unused processor time.
CLK. Use CLK functions when you want a function to be triggered directly
by a timer interrupt. These functions run as HWI functions and should take
minimal processing time. The default CLK object, PRD_clock, causes a
tick for the periodic functions. You can add additional CLK objects to run
at the same rate. However, you should minimize the time required to
perform all CLK functions because they run as HWI functions.
PRD. Use PRD functions when you want a function to run at a rate based
on a multiple of the on-device timer’s low-resolution rate or another event
(such as an external interrupt). These functions run as SWI functions.
PRD versus SWI. All PRD functions run at the same SWI priority, so one
PRD function cannot preempt another. However, PRD functions can post
lower-priority software interrupts for lengthy processing routines. This