Send a message to a channel
#include <sys/neutrino.h> long MsgSend( int coid, const void* smsg, size_t sbytes, void* rmsg, size_t rbytes ); long MsgSend_r( int coid, const void* smsg, size_t sbytes, void* rmsg, size_t rbytes );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The MsgSend() and MsgSend_r() kernel calls send a message to a process's channel via the connection identified by coid.
These functions are identical except in the way they indicate errors. See the Returns section for details.
The number of bytes transferred is the minimum of that specified by both the sender and the receiver. The send data isn't allowed to overflow the receive buffer area provided by the receiver. The reply data isn't allowed to overflow the reply buffer area provided.
The sending thread becomes blocked waiting for a reply. If the receiving process has a thread that's RECEIVE-blocked on the channel, the transfer of data into its address space occurs immediately, and the receiving thread is unblocked and made ready to run. The sending thread becomes REPLY-blocked. If there are no waiting threads on the channel, the sending thread becomes SEND-blocked and is placed in a queue (perhaps with other threads). In this case, the actual transfer of data doesn't occur until a receiving thread receives on the channel. At this point, the sending thread becomes REPLY-blocked.
MsgSend() is a cancellation point for the ThreadCancel() kernel call; MsgSendnc() isn't.
Blocking states
Native networking
When a client sends a message to a remote server, the client is effectively sending the message via its local microkernel; the network manager does the actual work. The local network manager negotiates with the remote network manager and causes the message to be delivered there. However, the remote manager is the one that actually delivers the message to the server.
This message transfer from the remote manager to the server is accomplished via a special nonblocking message pass.
The only impact on the client is the latency of the message-passing operations. This is purely a function of the network link speed and the overhead associated with the protocol (i.e. lsm-qnet.so for native networking) that io-pkt* uses.
The client still remains blocked in its MsgSend(), and unblocks only on account of a signal, a kernel timeout, or the completion of its function.
The only difference between MsgSend() and MsgSend_r() is the way they indicate errors:
Any other return value is the status from MsgReply*().
If the message passing itself failed, the errors include the following:
If the message passing succeeded, but the server called MsgError(), the error code can be whatever the server wants it to be.
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
The maximum size for a one-part message depends on the architecture: