Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change the way the threads are stopped, not killing the JVM at the end of the simulation.
[simgrid.git] / examples / pingPong / Sender.java
1 /*
2  * Sender of basic ping/pong example
3  *
4  * Copyright 2006,2007,2010 The SimGrid Team. All rights reserved. 
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. 
8  */
9 package pingPong;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.HostNotFoundException;
12 import org.simgrid.msg.Msg;
13 import org.simgrid.msg.MsgException;
14 import org.simgrid.msg.Process;
15
16 public class Sender extends Process {
17         public Sender(Host host, String name, String[]args) {
18                 super(host,name,args);
19         }
20     private final double commSizeLat = 1;
21     final double commSizeBw = 100000000;
22    
23     public void main(String[] args) throws MsgException {
24         
25        Msg.info("hello!");
26         
27        int hostCount = args.length;
28         
29        Msg.info("host count: " + hostCount);
30        String mailboxes[] = new String[hostCount]; 
31        double time;
32        double computeDuration = 0;
33        PingPongTask task;
34         
35        for(int pos = 0; pos < args.length ; pos++) {
36           try {
37              mailboxes[pos] = Host.getByName(args[pos]).getName();
38           } catch (HostNotFoundException e) {
39              Msg.info("Invalid deployment file: " + e.toString());           
40              System.exit(1);
41           }
42         }
43         
44         for (int pos = 0; pos < hostCount; pos++) { 
45            time = Msg.getClock(); 
46             
47            Msg.info("sender time: " + time);
48            
49            task = new PingPongTask("no name",computeDuration,commSizeLat);
50            task.setTime(time);
51             
52            task.send(mailboxes[pos]);
53         } 
54         
55         Msg.info("goodbye!");
56     }
57 }