tk_snd_mbf

Send Message to Message Buffer

See Also

[C Language Interface]

ER ercd = tk_snd_mbf ( ID mbfid, VP msg, INT msgsz, TMO tmout ) ;

[Parameters]

ID	mbfid	Message buffer ID


INT	msgsz	Send message size (in bytes)


VP	msg	Start address of send message packet


TMO	tmout	timeout




[Return Parameters]

ER	ercd	Error code

[Error Codes]

E_OK	Normal completion


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


E_NOEXS	Object does not exist (the message buffer specified in mbfid does not exist)


E_PAR	Parameter error (msgsz ( 0, msgsz > maxmsz, value in msg cannot be used, or tmout ( (-2))


E_DLT	The object being waited for was deleted (message buffer was deleted while waiting)


E_RLWAI	Wait state released (tk_rel_wai received in wait state)


E_TMOUT	Polling failed or timeout


E_CTX	Context error (issued from task-independent portion or in dispatch disabled state)

[Description]

Sends the message at the address specified in msg to the message buffer specified in mbfid. The message size is indicated in @msg@sz. This system call copies @msg@sz bytes starting from msg to the message queue of message buffer mbfid. The message queue is implemented as a ring buffer.

If msgsz is larger than the maxmsz specified with tk_cre_mbf, error code E_PAR is returned.

If there is not enough available buffer space to accommodate message msg in the message queue, the task issuing this system call goes to send wait state and is queued waiting for buffer space to become available (send queue). Waiting tasks are queued in either FIFO or priority order, depending on the settings specified at message buffer creation with tk_cre_mbf.

A maximum wait time (timeout) can be set in tmout. If the tmout time elapses before the wait release condition is met (before there is sufficient buffer space), the system call terminates, returning timeout error code E_TMOUT.

Only positive values can be set in tmout. The time base for tmout (time unit) is the same as that for system time (= 1 ms).

When TMO_POL = 0 is set in tmout, this means 0 was specified as the timeout value, and E_TMOUT is returned without entering WAIT state if there is not enough buffer space.

When TMO_FEVR =(-1) is set in tmout, this means infinity was specified as the timeout value, and the task continues to wait for buffer space to become available, without timing out.

A message of size 0 cannot be sent. When msgsz ( 0 is specified, error code E_PAR is returned.

When this system call is invoked from a task-independent portion or in dispatch disabled state, error code E CTX is returned; but in the case of tmout = TMO POL, there may be implementations that enable execution from a task-independent portion or in dispatch disabled state.

[Difference with T-Kernel]

E_DISWAI does not exist in error codes. This is because in µT-Kernel, there is no wait-disabled function.

[Porting Guideline]

Note that msgsz is of INT type and the range of values that can be specified may vary depending on the system. For example, in 16-bit environments, the maximum size of message that can be transmitted at a time may be limited to 32767 (approximately 32KB).

Comments

Click here to Post a Comment