Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ahem. When exactly did I kill my good examples?
[simgrid.git] / examples / pingPong / Receiver.java
1 /*
2  * $Id$
3  *
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier         
5  * All rights reserved. 
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. 
9  */
10 package pingPong;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.Process;
15
16 public class Receiver extends Process {
17         
18    final double commSizeLat = 1;
19    final double commSizeBw = 100000000;
20     
21    public void main(String[] args) throws MsgException {
22         
23       Msg.info("hello!");
24       double communicationTime=0;
25
26       double time = Msg.getClock();
27     
28       Msg.info("try to get a task");
29         
30       PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
31       double timeGot = Msg.getClock();
32       double timeSent = task.getTime();
33             
34       Msg.info("Got at time "+ timeGot);
35       Msg.info("Was sent at time "+timeSent);
36       time=timeSent;
37             
38       communicationTime=timeGot - time;
39       Msg.info("Communication time : " + communicationTime);
40             
41       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
42             
43       Msg.info("goodbye!");
44     }
45 }