SWI_raisepri
2-446
C Interface
Syntax
key = SWI_raisepri(mask);
Parameters
Uns
mask;
/* mask of desired priority level */
Return Value
Uns
key;
/* key for use with SWI_restorepri */
Reentrant
yes
Description
SWI_raisepri is used to raise the priority of the currently running SWI to
the priority mask passed in as the argument. SWI_raisepri can be used
in conjunction with SWI_restorepri to provide a mutual exclusion
mechanism without disabling SWIs.
SWI_raisepri should be called before a shared resource is accessed, and
SWI_restorepri should be called after the access to the shared resource.
A call to SWI_raisepri not followed by a SWI_restorepri keeps the SWI's
priority for the rest of the processing at the raised level. A SWI_post of
the SWI posts the SWI at its original priority level.
A SWI object’s execution priority must range from 0 to 14. The highest
level is SWI_MAXPRI (14). The lowest is SWI_MINPRI (0). Priority zero
(0) is reserved for the KNL_swi object, which runs the task scheduler.
SWI_raisepri never lowers the current SWI priority.
Constraints and
Calling Context
❏
SWI_raisepri cannot be called from an HWI or TSK level.
Example
/* raise priority to the priority of swi_1 */
key = SWI_raisepri(SWI_getpri(&swi_1));
--- access shared resource ---
SWI_restore(key);
See Also
SWI_raisepri
Raise a SWI’s priority