Message Passing
Message Passing is a way for processes to communicate and synchronize by sending and receiving messages. It works well in distributed systems and multiprocessors.
Key Points:
- Send (destination, message): A process sends a message to another process.
- Receive (source, message): A process gets a message from another process.
The receiver cannot receive a message until it has been sent by another process.
Synchronization
- send primitive extecuted
- sending process is blocked until the message is received, or it is not.
- receive primitive extecuted
- If a message has previously been sent, the message is received and execution continues.
- If there is no waiting message, then either
- the process is blocked until a message arrives
- the process continues to execute, abandoning the attempt to receive.
Types of Message Passing:
- Blocking: The sender or receiver waits until the message is sent/received.
- Nonblocking: The sender or receiver continues without waiting.
Common Combinations:
- Blocking send, blocking receive: Both wait (tight synchronization).
- Nonblocking send, blocking receive: Sender continues, receiver waits.
- Nonblocking send, nonblocking receive: Both continue without waiting.
Addressing: