MBX_pend
Application Program Interface
2-199
C Interface
Syntax
status = MBX_pend(mbx, msg, timeout);
Parameters
MBX_Handle mbx;
/* mailbox object handle */
Ptr
msg;
/* message pointer */
Uns
timeout;
/* return after this many system clock ticks */
Return Value
Bool
status;
/* TRUE if successful, FALSE if timeout */
Description
If the mailbox is not empty, MBX_pend copies the first message into msg
and returns TRUE. Otherwise, MBX_pend suspends the execution of the
current task until MBX_post is called or the timeout expires. The actual
time of task suspension can be up to 1 system clock tick less than timeout
due to granularity in system timekeeping.
If timeout is SYS_FOREVER, the task remains suspended until
MBX_post is called on this mailbox. If timeout is 0, MBX_pend returns
immediately.
If timeout expires (or timeout is 0) before the mailbox is available,
MBX_pend returns FALSE. Otherwise MBX_pend returns TRUE.
A task switch occurs when calling MBX_pend if the mailbox is empty and
timeout is not 0, or if a higher priority task is blocked on MBX_post.
Constraints and
Calling Context
❏
This API can be called from a TSK with any timeout value, but if
called from an HWI or SWI the timeout must be 0.
❏
If you need to call MBX_pend within a TSK_disable/TSK_enable
block, you must use a timeout of 0.
❏
MBX_pend cannot be called from the program’s main() function.
See Also
MBX_pend
Wait for a message from mailbox