Message Passing: Difference between revisions

m
Reverted edits by Melina148 (talk) to last revision by Khaledhammouda
[unchecked revision][unchecked revision]
(Changed Unreliable to Best-Effort)
m (Reverted edits by Melina148 (talk) to last revision by Khaledhammouda)
 
(5 intermediate revisions by 3 users not shown)
Line 12:
==Synchronous vs Asynchronous==
;synchronous
:Process A delivers the message directly to process B. If process B is not ready to receive at the moment of sending, Process A is suspended and queued upon Process B's 'sending' queue, until Process B is receiving. Using this method, you don't need to care for message queues - but you enqueue processes. Note that if process B is waiting to receive a message from process A, and the message fails to be delivered (due to an error, or some failure in the message delivery system, for example) then process B will block indefinitely.
 
;asynchronous
:Process A sends the message to Process B. The message is copied to a dedicated region in kernel space and attached to Process B's message queue (lets call it the Post box). The next time, Process B looks into its postbox, it will retrieve the message. You can have processes block for receiving a message or just stroll by and check whether there is something to fetch. One could call this method "store and forward message passing". The main benefit of asynchronous messaging is that it allows a single thread/process to wait for the results of many unrelated "requests" at the same time. However, any erroneous (or malicious) process can repeatedly spam messages in quick succession to other processes, thus tying up system resources in a denial-of-service attack.
 
We may note that in the synchronous approach, A has the guarantee that B received the message when the deliver call terminates, which makes it especially interesting for local RPC. It should be noted that it can be very difficult to implement standard C library functions without this guarantee.
Line 35:
 
To solve situations when a server is willing to receive messages from different ports (and synchronous messaging is used), we need a select-like interface that will allow reception of a message from any port p in a given set of ports.
 
==Mailboxes==
There may be some cases in which a thread will want to broadcast the same message to multiple threads at once, or perhaps a set of producer threads has to communicate with another set of consumer threads. In such cases, mailboxes can queue messages for multiple receivers. Mailboxes are similar to ports, except multiple recipients may retrieve messages instead of just one. A mailbox is not owned by a single thread, but is a common resource provided by the OS that's shared among the receiving threads. The order in which messages are received may either be ''first-in-first-out'' (FIFO) or based on message priority.
 
==Variable or Fixed Messages Size==
Line 46 ⟶ 49:
* [[Remote_Procedure_Call|Remote Procedure Call (RPC)]]
* [[Message Passing Tutorial]]
* [[IPC Data Copying methods]]
 
=== Threads ===
Line 53 ⟶ 57:
=== External Links ===
*[[Wikipedia:Message Passing | Message Passing]] on Wikipedia
*[[Wikipedia:Message queue | Message Queue]] on Wikipedia
 
[[Category:IPC]]
[[Category:OS theory]]
Anonymous user