[Simgrid-user] MSG Communications issues

Arnaud Legrand arnaud.legrand at imag.fr
Wed Sep 7 09:13:06 CEST 2011


Le lundi 08 août 2011 à 19:55 +0200, ENDERLIN Christophe a écrit :
> In my code, when a node has to send a task to another one, it uses the
> function
> MSG_task_dsend() because I want this sending to be absolutely
> non-blocking.
> It's up to the receiver to destroy the communication object, then.
> The receiver has (sometimes) to keep on listening as long as it
> doesn't receive
> the answer it's expecting. That's why it uses then MSG_task_receive().
> The problem is that I don't know how to destroy the communication
> object in this case.

The receiver should just call MSG_task_destroy on the task once it has
finished using it. That's all. With dsend, the sender does not have
access to any MSG_comm_t. Since you use irecv, you get a MSG_comm_t,
which you should destroy with MSG_comm_destroy.

> So, I wonder if I'm doing things right by using a non blocking
> function to send and a blocking one to receive ? Should I use
> MSG_task_irecv() instead of MSG_task_receive() ?

You can use both. It depends on what you want to do.

> 1) How to destroy a communication object when using
> MSG_task_receive() ?

The communication object is here to get information about the status of
the communication. When using MSG_task_receive, there is no need to have
such a communication object since MSG_task_receive is a blocking
function. So no need to destroy it...

> 2) Is it correct to receive with MSG_task_receive() a task that's been
> sent with a MSG_task_dsend() ?

Yep. This should not be a problem.

> 3) Is there really a risk of loss of message if a node sleeps too long
> before listening again, when
>     using MSG_task_irecv() ?

No. When you use MSG_task_irecv, it means you did post an asynchronous
reception. So the message will start arriving whenever the sender is
ready even if the receiver is sleeping. But the sleeper will realize it
has received a message only when it wakes up and checks for the
communication object returned by the irecv. Note also that there are
many functions that handle timeouts (e.g., MSG_task_get_with_timeout)
that may be useful in your case.



"Chaque fois que vous développez un nouveau produit vous travaillez en
étroite relation avec la NSA"
-- Ira Rubenstein, avocat de Microsoft

More information about the Simgrid-user mailing list