asynchronous send vs. nonblocking send

48 views
Skip to first unread message

g.nan...@gmail.com

unread,
Aug 14, 2016, 12:02:17 PM8/14/16
to minix3
Hi there,

I noticed there are two functions for sending message:
mini_senda() and mini_send().
The latter can be passed a flag indicating that it is NON_BLOCKING.
Don't they mean the same thing: the sender don't have to wait,
if the receiver is not ready.

Is there any difference between asynchronous and nonblocking send
from any possible point of view?

best regards,
Nand

David van Moolenbroek

unread,
Aug 15, 2016, 11:30:05 AM8/15/16
to minix3
Hello,


On Sunday, August 14, 2016 at 6:02:17 PM UTC+2, g.nang2000 wrote:
Is there any difference between asynchronous and nonblocking send
from any possible point of view?

Both types of send calls are nonblocking in the sense that they do not block the sending process. Also, both types will deliver the message instantly to the destination process if that process is ready to receive the message at the time of the send call. However, these types of send calls do behave differently in the case that the destination process is *not* ready to receive the message at the time of the send call: in that case, the nonblocking send call will return an error code and not deliver the message at all, while the asynchronous send call will make the kernel deliver the message later, in the background so to speak, as soon as the destination process is ready to receive it.

In practice, the non-blocking send call (that is, ipc_sendnb()) is used only when the sender already knows that the destination process is (or should be) ready to receive the message, typically because that process is blocked in an ipc_sendrec() call. The asynchronous send call (usually through asynsend()) is used when the sender needs to make sure that the destination process gets the message eventually even though that process may be doing something else at the time. So why not simply always use asynchronous send calls instead of nonblocking send calls? That's easy: the nonblocking-send call has (slightly) better performance.

I hope that helps!

Regards,
David

g.nan...@gmail.com

unread,
Aug 15, 2016, 1:25:49 PM8/15/16
to minix3
Hello,
that really helps a lot.
I should have looked deeper into the code, the names don't tell all.
thank you.

Nand
Reply all
Reply to author
Forward
0 new messages