WaitPort

Waits for a message to arrive.

Synopsis

Item WaitPort( Item mp, Item msg )

Description

The procedure puts the calling task into wait state until a message is received at the specified message port. When a task is in wait state, it uses no CPU time.

The task can wait for a specific message by providing the item number of the message in the message argument. To wait for any incoming message, the task uses 0 as the value of the message argument.

Note: If the desired message is already in the message queue for the specified message port, the procedure returns immediately. If the message never arrives, the procedure may never return.

When the message arrives, the task is moved from the wait queue to the ready queue, the item number of the message is returned as the result, and the message is removed from the message port.

Arguments

mp
The item number of the message port to check for incoming messages.
msg
The item number of the message to wait for. If this argument is 0, control is returned to the task when any message arrives at the specified message port.

Return Value

The procedure returns the item number of the incoming message or an error code if an error occurs.

Implementation

Folio call implemented in kernel folio V20. Became an SWI in kernel folio V24.

Associated Files

msgport.h
ANSI C Prototype
clib.lib
ARM Link Library

See Also

GetMsg(), ReplyMsg(), SendMsg()