Software Interrupts
4-32
When an SWI has been posted using SWI_inc, once the SWI Manager calls
the corresponding SWI function for execution, the SWI function can access
the SWI object mailbox to know how many times it was posted before it was
scheduled to run, and proceed to execute the same routine as many times as
the value of the mailbox.
Figure 4-7. Using SWI_inc to Post an SWI
Program configuration
SWI object myswi Function myswiFxn()
Program
execution
· Calls SWI_inc(&myswi)
· myswi is posted
· Calls SWI_inc(&myswi)
· myswi is posted again
before it is scheduled
for execution
· 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
2
0 2
0 2
· myswiFxn() is
preempted by ISR that
calls SWI_inc(&myswi)
· myswi is added to the
posted SWI queue
· myswiFxn() continues
execution
1 2
1 2
myswiFxn()
{ . . .
repetitions = SWI_getmbox();
while (repetitions --){
‘run SWI routine‘
}
. . .
}