In QNX a message is a packet of bytes that is synchronously transmitted from one process to another. QNX attaches no meaning to content of a message. To communicate directly with one another, cooperating processes use these C language functions:
These functions can be used locally or across the network.
Next picture illustrates outlines a simple sequence of events in which two processes, Process A and Process B, use Send(), Receive(), and Reply()to communicate with each other:
When a process is not allowed to continue executing, because it must wait for some part of the message protocol to end, the process is said to be blocked. The following table summarizes the blocked states of processes:
If a process has issued a: | the process is: |
Send() request, and the message it has sent has not yet received by the recipient process | SEND-blocked |
Send() request, and the message has been received by the recipient process, but that process has not yet replied | REPLY-blocked |
Receive() request, but has not yet received a message | RECEIVE-blocked |
The QNX provides these advanced massage-passing facilities:
If a process need determine whether messages are pending without becoming RECEIVE-blocked, the process could use the Creceive() function to read a message, if one became available, yet return immediately if no further messages were pending.
Sometimes it is desirable to read or write only a part of a message at a time so that you can use the buffer space already allocated for the message instead of allocating a separate work buffer. It can be done by using Readmsg() and Writemsg() C-functions.
A message may have a fixed length header followd by a variable amount of data. So that it components will be efficiently sent or received without being copied into a temporary work buffer, a multi-part message can be constructed from two or more separate message buffers. This facility helps QNX I/O managers, such as Dev and Fsys, achive their high performance. The following functions are avaliable to handle multi-part messages:
Multi-part messages can be specified with az mx control structure. The kernel assembles these into a single data stream:
Quantum begins all of its messages with a 16-bit word called message code. Note that Quantum's system processes use message codes in the following ranges:
0x0000 to 0x00FF | Process Manager messages |
0x0100 to 0x01FF | I/O messages (common to all I/O services) |
0x0200 to 0x02FF | Filesystem Manager messages |
0x0300 to 0x03FF | Device Manager messages |
0x0400 to 0x04FF | Network Manager messages |
0x0500 to 0x0FFF | Reserved for future Quantum system processes |