SWI_inc
Application Program Interface
2-441
C Interface
Syntax
SWI_inc(swi);
Parameters
SWI_Handle swi;
/* SWI object handle*/
Return Value
Void
Reentrant
no
Description
SWI_inc increments the value in SWI’s mailbox by 1 and posts the SWI
regardless of the resulting mailbox value. You can decrement a mailbox
value using SWI_dec, which only posts the SWI if the mailbox value is 0.
If a SWI is posted several times before it has a chance to begin
executing, because HWIs and higher priority SWIs are running, the SWI
only runs one time. If this situation occurs, you can use SWI_inc to post
the SWI. Within the SWI’s function, you could then use SWI_getmbox to
find out how many times this SWI has been posted since the last time it
was executed.
You specify a SWI’s initial mailbox value in the configuration. The mailbox
value is automatically reset when the SWI executes. To get the mailbox
value, use SWI_getmbox.
SWI_inc results in a context switch if the SWI is higher priority than the
currently executing thread.
Constraints and
Calling Context
❏
If this macro (API) is invoked outside the context of an HWI, interrupts
must be enabled.
❏
When called within an HWI, the code sequence calling SWI_inc must
be either wrapped within an HWI_enter/HWI_exit pair or invoked by
the HWI dispatcher.
Example
extern SWI_ObjMySwi;
/* ======== AddAndProcess ======== */
Void AddAndProcess(int count)
int i;
for (i = 1; I <= count; ++i)
SWI_inc(&MySwi);
}
See Also
SWI_inc
Increment SWI’s mailbox value and post the SWI