Message Passing
This is fundamental to understand, for building something like ROS. I think I have a high level good understand, but what I am learning in SE350 will help solidify this knowledge.
The following are different characteristics that we need to understand:
- Synchronization
- Addressing (direct vs. indirect)
- Format
- Queuing discipline
The 2 primitives:
1. Synchronization
Processes need to be synchronized to enforce Mutual Exclusion.
Both the sender and receiver can be blocking or nonblocking.
3 most common combinations:
- Blocking send, blocking receive (called a rendezvous): Both sender and receiver are blocked until message is delivered
- Nonblocking send, blocking receive: Sender continues on, Receiver is blocked until the requested message arrives
- Nonblocking send, nonblocking receive: Neither party is required to wait
2. Addressing
Direct addressing
- Send primitive includes a specific identifier of the destination process
- Receive primitive could know ahead of time from which process a message is expected
- Receive primitive could use source parameter to return a value when the receive operation has been performed
Indirect addressing
- Messages are sent to a shared data structure consisting of queues
- Queues are called mailboxes
- One process sends a message to the mailbox and the other process picks up the message from the mailbox
3. Message Format
4. Queuing Discipline
The simplest queueing discipline is FIFO, but this may not be sufficient if some messages are more urgent than others. An alternative is to allow the specifying of message priority, on the basis of message type or by designation by the sender. Another alternative is to allow the receiver to inspect the message queue and select which message to receive next.
Example
Solving the Producer-Consumer Problem using messages.