Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Better Java philosophy: create a new type of tasks to mean terminaison instead of...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Oct 2007 09:44:36 +0000 (09:44 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Oct 2007 09:44:36 +0000 (09:44 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4903 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/java/comm_time/FinalizeTask.java [new file with mode: 0644]
examples/java/comm_time/Master.java
examples/java/comm_time/Slave.java

diff --git a/examples/java/comm_time/FinalizeTask.java b/examples/java/comm_time/FinalizeTask.java
new file mode 100644 (file)
index 0000000..6fd6623
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * $Id: CommTimeTask.java 3685 2007-07-08 21:02:03Z mquinson $
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier         
+ * 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. 
+ */
+
+import simgrid.msg.*;
+
+public class FinalizeTask extends Task {
+       
+   public FinalizeTask() throws JniException, NativeException{
+      create("",0,0);
+   }
+}
+    
\ No newline at end of file
index a9dad92..f33c6c6 100644 (file)
@@ -53,8 +53,7 @@ public class Master extends simgrid.msg.Process {
                
       for (int i = 0; i < slavecount; i++) { 
                        
                
       for (int i = 0; i < slavecount; i++) { 
                        
-        CommTimeTask task = new CommTimeTask("finalize_" + i,0,0);
-        task.setData(221297);
+        FinalizeTask task = new FinalizeTask();
                        
         Msg.info("Send task to host : " + slaves[i].getName());
         channel.put(task,slaves[i]);
                        
         Msg.info("Send task to host : " + slaves[i].getName());
         channel.put(task,slaves[i]);
index 086a192..7c622a6 100644 (file)
@@ -20,24 +20,22 @@ public class Slave extends simgrid.msg.Process {
                
       while(true) {
         int a;
                
       while(true) {
         int a;
-        double time1,time2;
-         
-        time1 = Msg.getClock();
-        
-        CommTimeTask task = (CommTimeTask)channel.get();
-        time2 = Msg.getClock();
-                               
-        if(task.getData() == 221297) {
-           Msg.info("Received " + task.getName() + " " + getHost().getName());
+        double time1 = Msg.getClock();       
+        Task t = channel.get();        
+        double time2 = Msg.getClock();
+        if (t instanceof FinalizeTask) {
+           Msg.info("Received Finalize " + getHost().getName());
            break;
         }
            break;
         }
+        CommTimeTask task = (CommTimeTask)t;
             
         if(time1 < task.getTime())
           time1 = task.getTime();
         
             
         if(time1 < task.getTime())
           time1 = task.getTime();
         
-        Msg.info("Processing \"" + task.getName() + "\" " + getHost().getName() + 
+/*      Msg.info("Processing \"" + task.getName() + "\" " + getHost().getName() + 
                  " (Communication time : " +  (time2 - time1) + ")");
                  " (Communication time : " +  (time2 - time1) + ")");
-            
+*/          
         task.execute();
         
         
         task.execute();