Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Missing import in 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.Host;
12 import org.simgrid.msg.Msg;
13 import org.simgrid.msg.MsgException;
14 import org.simgrid.msg.Task;
15 import org.simgrid.msg.Process;
16
17 public class Receiver extends Process {
18         public Receiver(Host host, String name, String[]args) {
19                 super(host,name,args);
20         }
21    final double commSizeLat = 1;
22    final double commSizeBw = 100000000;
23     
24    public void main(String[] args) throws MsgException {
25         
26       Msg.info("hello!");
27       double communicationTime=0;
28
29       double time = Msg.getClock();
30     
31       Msg.info("try to get a task");
32         
33       PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
34       double timeGot = Msg.getClock();
35       double timeSent = task.getTime();
36             
37       Msg.info("Got at time "+ timeGot);
38       Msg.info("Was sent at time "+timeSent);
39       time=timeSent;
40             
41       communicationTime=timeGot - time;
42       Msg.info("Communication time : " + communicationTime);
43             
44       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
45             
46       Msg.info("goodbye!");
47     }
48 }