X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2033091e2339a120d594b4cbf81a89d72faa0d05..e2030cb82d5b8f8b39696794f036e5ffc435f9bf:/examples/java/comm_time/Slave.java diff --git a/examples/java/comm_time/Slave.java b/examples/java/comm_time/Slave.java index 086a1928ab..539fd34f59 100644 --- a/examples/java/comm_time/Slave.java +++ b/examples/java/comm_time/Slave.java @@ -1,8 +1,5 @@ /* - * $Id$ - * - * Copyright 2006,2007 Martin Quinson, Malek Cherier - * All rights reserved. + * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. @@ -11,38 +8,24 @@ import simgrid.msg.*; public class Slave extends simgrid.msg.Process { - - public void main(String[] args) throws JniException, NativeException { - - Msg.info("Hello i'm a slave"); + public void main(String[] args) throws MsgException { + if (args.length < 1) { + Msg.info("Slave needs 1 argument (its number)"); + System.exit(1); + } + + int num = Integer.valueOf(args[0]).intValue(); + Msg.info("Receiving on 'slave_"+num+"'"); - Channel channel = new Channel(0); - - while(true) { - int a; - double time1,time2; - - time1 = Msg.getClock(); + while(true) { + Task task = Task.receive("slave_"+num); - CommTimeTask task = (CommTimeTask)channel.get(); - time2 = Msg.getClock(); - - if(task.getData() == 221297) { - Msg.info("Received " + task.getName() + " " + getHost().getName()); + if (task instanceof FinalizeTask) { break; } - - if(time1 < task.getTime()) - time1 = task.getTime(); - - Msg.info("Processing \"" + task.getName() + "\" " + getHost().getName() + - " (Communication time : " + (time2 - time1) + ")"); - task.execute(); - - - } + } - Msg.info("I'm done. See you!" + getHost().getName()); - } + Msg.info("Received Finalize. I'm done. See you!"); + } } \ No newline at end of file