Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cb5c8083365ed9f69e37f44addcc4513dec1eb68
[simgrid.git] / examples / java / ping_pong / 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
11 import simgrid.msg.*;
12
13 public class Receiver extends simgrid.msg.Process {
14         
15    final double commSizeLat = 1;
16    final double commSizeBw = 100000000;
17     
18    public void main(String[] args) throws JniException, NativeException {
19         
20       Msg.info("hello!");
21       double communicationTime=0;
22
23       double time = Msg.getClock();
24       Channel channel = new Channel(0);
25     
26       Msg.info("try to get a task");
27         
28       PingPongTask task = (PingPongTask)channel.get();
29       double timeGot = Msg.getClock();
30       double timeSent = task.getTime();
31             
32       Msg.info("Got at time "+ timeGot);
33       Msg.info("Was sent at time "+timeSent);
34       time=timeSent;
35             
36       communicationTime=timeGot - time;
37       Msg.info("Communication time : " + communicationTime);
38             
39       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
40             
41       Msg.info("goodbye!");
42     }
43 }