tk_snd_mbx

Send Message to Mailbox

[C Language Interface]

ER ercd = tk_snd_mbx ( ID mbxid, T_MSG *pk_msg ) ;

[Parameters]

ID mbxid Mailbox ID

T_MSG* pk_msg Message packet address

[Return Parameters]

ER ercd Error code

[Error Codes]

E_OK Normal completion

E_ID Invalid ID number (mbxid is invalid or cannot be used)

E_NOEXS Object does not exist (the mailbox specified in mbxid does not exist)

E_PAR Parameter error (pk_msg is a value that cannot be used)

[Description]

Sends the message packet having pk_msg as its start address to the mailbox specified in mbxid. The message packet contents are not copied; only the start address (pk_msg) is passed at the time of message receipt.

If tasks are already waiting for messages in the same mailbox, the WAIT state of the task at the head of the queue is released, and the pk_msg passed to tk_snd_mbx is sent to that task, becoming a parameter returned by tk rcv mbx. If there are no tasks waiting for messages in the specified mailbox, the sent message goes in the message queue of that mailbox. In neither case does the task issuing tk_snd_mbx enter WAIT state.

pk_msg is the start address of the packet containing the message, including header. The message header has the following format.


typedef struct t_msg {
	?	?	/* Impleme ntation-dep endent cont ents (fixed size) */
} T_MSG;
typedef struct t_msg_pri {
	T_MSG	msgque;	/* message queue area */
	PRI	msgpri;	/* message priority */
} T_MSG_PRI;

The message header is T_MSG (if TA_MFIFO attribute is specified) or T_MSG_PRI (if TA_MPRI). In either case the message header has a .xed size, which can be obtained by sizeof(T_MSG) or sizeof (T_MSG_PRI). The actual message must be put in the area after the header. There is no limit on message size, which may be variable-length.

[Additional Notes]

Messages are sent by tk_snd_mbx regardless of the status of the receiving tasks. In other words, message sending is asynchronous. What waits in the queue is not the task itself, but the sent message. So while there are queues of waiting messages and receiving tasks, the sending task does not go to WAIT state.

Comments