Download TMS320 DSP/BIOS 6 User's Guide (Rev. D

Transcript
Software Interrupts
If Swis are enabled, the Swi Manager checks the priority of the posted Swi
object against the priority of the thread that is currently running. If the thread
currently running is the background Idle Loop or a lower priority Swi, the Swi
Manager removes the Swi from the list of posted Swi objects and switches
the CPU control from the current thread to start execution of the posted Swi
function.
If the thread currently running is a Swi of the same or higher priority, the Swi
Manager returns control to the current thread, and the posted Swi function
runs after all other Swis of higher priority or the same priority that were
previously posted finish execution.
There are two important things to remember about Swi:
❏
When a Swi starts executing it must run to completion without blocking.
❏
When called from within a Hwi, the code sequence calling any Swi
function that can trigger or post a Swi must be invoked by the Hwi
dispatcher.
Swi functions can be preempted by threads of higher priority (such as a Hwi
or a Swi of higher priority). However, Swi functions cannot block. You cannot
suspend a Swi while it waits for something—like a device—to be ready.
If a Swi is posted multiple times before the Swi Manager has removed it from
the posted Swi list, its Swi function executes only once, much like a Hwi is
executed only once if the Hwi is triggered multiple times before the CPU
clears the corresponding interrupt flag bit in the interrupt flag register. (See
Section 2.4.5, Using a Swi Object’s Trigger Variable, page 2-27, for more
information on how to handle Swis that are posted multiple times before they
are scheduled for execution.)
Applications should not make any assumptions about the order in which Swi
functions of equal priority are called. However, a Swi function can safely post
itself (or be posted by another interrupt). If more than one is pending, all Swi
functions are called before any tasks run.
2.4.5
Using a Swi Object’s Trigger Variable
Each Swi object has an associated 32-bit trigger variable for C6x targets and
a 16-bit trigger variable for C5x targets. This is used either to determine
whether to post the Swi or to provide values that can be evaluated within the
Swi function.
Swi_post(), Swi_or(), and Swi_inc() post a Swi object unconditionally:
❏
Swi_post() does not modify the value of the Swi object trigger when it is
used to post a Swi.
Threading Modules
2-27