Software Interrupts
Thread Scheduling 4-33
If more than one event must always happen for a given software interrupt to
be triggered, SWI_andn should be used to post the corresponding SWI object
as shown in Figure 4-8. For example, if a software interrupt must wait for input
data from two different devices before it can proceed, its mailbox should have
two set bits when the SWI object was configured. When both routines that
provide input data have completed their tasks, they should both call
SWI_andn with complementary bitmasks that clear each of the bits set in the
SWI mailbox default value. Hence, the software interrupt is posted only when
data from both processes is ready.
Figure 4-8. Using SWI_andn to Post an SWI
In some situations the SWI function can call different routines depending on
the event that posted it. In that case the program can use SWI_or to post the
SWI object unconditionally when an event happens. This is shown in Figure
4-9. The value of the bitmask used by SWI_or encodes the event type that
triggered the post operation, and can be used by the SWI function as a flag
that identifies the event and serves to choose the routine to execute.
Program configuration
SWI object myswi Function myswiFxn()
Program
execution
· Calls
SWI_andn(&myswi, 0x1)
· myswi is not posted
· Calls
SWI_andn(&myswi, 0x2)
· myswi is posted
· SWI manager removes
myswi from the posted
SWI queue
· myswiFxn() is scheduled
for execution
· myswiFxn() starts
execution
Mailbox
value
Value returned by
SWI_getmbox
0
...
1 1
...
0
...
1 0
0
...
0 0
0
...
1 1
0
...
1 1
...
...
0
...
0 0
0
...
0 0