Search code examples
javasimgrid

SimGrid. How to receive and send data while executing task?


What method or idea I should use for simulation following situation.

There are master, worker1 (host1) and worker2(host2). Currently worker1 is executing some data, but worker2 is free. Master have to send instruction to worker2 about downloading data from worker1 and start to execute them.

The idea was to send messageTask from master to worker2 --> worker2 sends messageTask to worker1 --> worker1 sends task(name, flopsamount, byteSize) to worker2 --> worker2 receives and executes it.

But how can worker1 receive messageTask from worker2 if worker1 is busy by executing his task? How can worker1 send data while he is executing task? Or maybe there are another method for worker2 to download data from busy worker1?

UPDATED This is a piece of code for worker2.

MessageTask messageTask = new MessageTask();
messageTask.dsend(mailbox_worker1)

For worker1

try {
    task.execute(); // Currently worker1 is here, in other words, worker1 is exectuing some another task
} catch (TaskCancelledException e) {
}

How worker1 will receive messageTask and send back to worker2 real data (without interrupting of executing his current task)?

UPDATED

Is it correct deployment.xml?

  <process host="Tier1_1" function="LHCb.Process1">
     <argument value="1"/>  <!-- Input mailbox -->
  </process>

  <process host="Tier1_1" function="LHCb.Process2">
     <argument value="1"/>  <!-- Input mailbox -->
  </process>

Solution

  • There is at least two ways to do stuff while communicating. You can either use detached sends, which means that you don't care about whether the communication works or not, or asynchronous communications.

    There is an example of the first mechanism in this directory: examples/java/async/dsend while the other mechanism is not exemplified in Java yet. You will have to check the C example for now.

    Now, in the updated part, you want to do stuff while executing something. Since there is nothing like asynchronous execution (yet), you will have to start another process on the same host to handle the communications while the first host computes stuff.