Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge scm.gforge.inria.fr:/gitroot/simgrid/simgrid-java
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Tue, 12 Jun 2012 13:11:11 +0000 (15:11 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Tue, 12 Jun 2012 13:11:11 +0000 (15:11 +0200)
31 files changed:
CMakeLists.txt
examples/async/AsyncTest.java
examples/basic/BasicTest.java [deleted file]
examples/basic/basic.tesh [deleted file]
examples/basic/deploy.xml [deleted file]
examples/master_slave_bypass/platform.xml
examples/masterslave/FinalizeTask.java [moved from examples/basic/FinalizeTask.java with 93% similarity]
examples/masterslave/Forwarder.java [moved from examples/basic/Forwarder.java with 98% similarity]
examples/masterslave/Master.java [moved from examples/basic/Master.java with 98% similarity]
examples/masterslave/Masterslave.java [new file with mode: 0644]
examples/masterslave/README [moved from examples/basic/README with 100% similarity]
examples/masterslave/Slave.java [moved from examples/basic/Slave.java with 98% similarity]
examples/masterslave/deploy.xml [new file with mode: 0644]
examples/masterslave/masterslave.tesh [new file with mode: 0644]
examples/masterslave/masterslaveDeployment.xml [moved from examples/basic/basicDeployment.xml with 67% similarity]
examples/migration/Emigrant.java [new file with mode: 0644]
examples/migration/Migration.java [new file with mode: 0644]
examples/migration/Policeman.java [new file with mode: 0644]
examples/migration/migration.tesh [new file with mode: 0644]
examples/migration/migrationDeployment.xml [new file with mode: 0644]
examples/suspend/DreamMaster.java
examples/suspend/LazyGuy.java
org/simgrid/msg/HostFailureException.java
org/simgrid/msg/Msg.java
org/simgrid/msg/Mutex.java
org/simgrid/msg/Process.java
org/simgrid/msg/ProcessKilledError.java
src/jmsg_process.c
src/jmsg_process.h
src/jmsg_synchro.c
src/smx_context_java.c

index 55a5fad..327131a 100644 (file)
@@ -120,13 +120,6 @@ set(JAVA_EXAMPLES
        examples/async/Forwarder.java
        examples/async/Master.java  
        examples/async/Slave.java
-       examples/startKillTime/Slave.java
-       examples/basic/FinalizeTask.java
-       examples/basic/Forwarder.java
-       examples/basic/Master.java
-       examples/basic/BasicTest.java
-       examples/basic/Slave.java
-
   examples/bittorrent/Bittorrent.java
   examples/bittorrent/Common.java
   examples/bittorrent/Connection.java
@@ -146,6 +139,11 @@ set(JAVA_EXAMPLES
        examples/commTime/Master.java
        examples/commTime/Slave.java
        examples/commTime/CommTimeTest.java
+       examples/masterslave/FinalizeTask.java
+       examples/masterslave/Forwarder.java
+       examples/masterslave/Master.java
+       examples/masterslave/Masterslave.java
+       examples/masterslave/Slave.java 
        examples/master_slave_bypass/Master.java
        examples/master_slave_bypass/MsBypass.java
        examples/master_slave_bypass/Slave.java
@@ -154,6 +152,9 @@ set(JAVA_EXAMPLES
        examples/master_slave_kill/MsKill.java
        examples/master_slave_kill/Slave.java
        examples/master_slave_kill/FinalizeTask.java
+       examples/migration/Emigrant.java
+       examples/migration/Migration.java
+       examples/migration/Policeman.java
        examples/mutualExclusion/centralized/MutexCentral.java
        examples/mutualExclusion/centralized/GrantTask.java
        examples/mutualExclusion/centralized/Coordinator.java
@@ -165,6 +166,7 @@ set(JAVA_EXAMPLES
        examples/pingPong/Receiver.java
        examples/pingPong/PingPongTest.java
        examples/startKillTime/Master.java
+       examples/startKillTime/Slave.java
        examples/startKillTime/StartKillTime.java
        examples/suspend/DreamMaster.java
        examples/suspend/LazyGuy.java
@@ -179,17 +181,17 @@ ${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
 )
 
 set(XML_FILES
-    examples/commTime/commTimeDeployment.xml
-    examples/mutualExclusion/ring3.xml
-    examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
     examples/platform.xml
-    examples/pingPong/pingPongDeployment.xml
-    examples/basic/basicDeployment.xml
-    examples/basic/deploy.xml
-    examples/master_slave_bypass/platform.xml
-    examples/master_slave_kill/platform.xml
     examples/async/asyncDeployment.xml
     examples/bittorrent/bittorrent.xml
+    examples/commTime/commTimeDeployment.xml
+    examples/masterslave/masterslaveDeployment.xml
+    examples/masterslave/deploy.xml
+    examples/master_slave_bypass/platform.xml
+    examples/master_slave_kill/platform.xml
+    examples/mutualExclusion/ring3.xml  
+    examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
+    examples/pingPong/pingPongDeployment.xml
 )
 
 set(source_to_pack
@@ -262,12 +264,13 @@ add_custom_command(
        OUTPUT  ${JAVA_EXAMPLES_CLASS}
        DEPENDS ${JAVA_EXAMPLES}
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java
-  COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java  
-       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
+  COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/masterslave/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/migration/*.java
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                      
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.java    
@@ -297,19 +300,20 @@ INCLUDE(CTest)
 ENABLE_TESTING()
 
 ADD_TEST(async           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh)
-ADD_TEST(basic           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/basic/basic.tesh)
 ADD_TEST(bittorrent      ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh)
 ADD_TEST(bypass          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh)
 ADD_TEST(commTime        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh)
 ADD_TEST(chord          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh)
 ADD_TEST(kill            ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
+ADD_TEST(masterslave     ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh)
+ADD_TEST(migration       ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh)
 ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
 ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
 ADD_TEST(priority        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
 ADD_TEST(startKillTime   ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
 ADD_TEST(suspend         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
 #Don't forget to put new test in this list!!!
-set(test_list async basic bittorrent bypass chord commTime kill mutualExclusion pingPong priority startKillTime)
+set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime)
 
 ##########################################
 # Set the  DYLD_LIBRARY_PATH for mac     #
index 1e14632..f8abd33 100644 (file)
@@ -22,23 +22,16 @@ public class AsyncTest {
                /* initialize the MSG simulation. Must be done before anything else (even logging). */
                Msg.init(args);
 
-               if(args.length == 0) {
-                       Msg.createEnvironment("async_platform.xml");
-                       Msg.deployApplication("async_deployment.xml");
-
-               } else if (args.length < 2) {
-
-
+           if (args.length < 2) {              
                        Msg.info("Usage   : Async platform_file deployment_file");
-                       Msg.info("example : Async async_platform.xml async_deployment.xml");
-                       System.exit(1);
-               } else {
-
-                       /* construct the platform and deploy the application */
-                       Msg.createEnvironment(args[0]);
-                       Msg.deployApplication(args[1]);
+                       Msg.info("example : Async basic_platform.xml basic_deployment.xml");
+                       System.exit(1); 
                }
 
+               /* construct the platform and deploy the application */
+               Msg.createEnvironment(args[0]);
+               Msg.deployApplication(args[1]);
+
                /*  execute the simulation. */
                Msg.run();
        }
diff --git a/examples/basic/BasicTest.java b/examples/basic/BasicTest.java
deleted file mode 100644 (file)
index af6f35b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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. 
- */
-
-package basic;
-
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.NativeException;
-
-public class BasicTest {
-   
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java simgrid.msg.Msg
-    * which also contains such a launcher
-    */
-   
-    public static void main(String[] args) throws NativeException {
-       
-       /* initialize the MSG simulation. Must be done before anything else (even logging). */
-       Msg.init(args);
-
-       if(args.length == 0) {
-               Msg.createEnvironment("basic_platform.xml");
-               Msg.deployApplication("basic_deployment.xml");
-          
-       } else if (args.length < 2) {
-
-               
-         Msg.info("Usage   : Basic platform_file deployment_file");
-         Msg.info("example : Basic basic_platform.xml basic_deployment.xml");
-         System.exit(1);
-       } else {
-               
-       /* construct the platform and deploy the application */
-       Msg.createEnvironment(args[0]);
-       Msg.deployApplication(args[1]);
-       }
-       
-       /*  execute the simulation. */
-        Msg.run();
-    }
-}
diff --git a/examples/basic/basic.tesh b/examples/basic/basic.tesh
deleted file mode 100644 (file)
index f05eba9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#! ./tesh
-
-! output sort
-
-$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar basic/BasicTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/basic/basicDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (0:@) Ready to run MSG_MAIN
-> [  0.000000] (1:basic.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process
-> [  0.000000] (2:basic.Forwarder@Jackson) Receiving on 'slave_0'
-> [  0.000000] (3:basic.Forwarder@Casavant) Receiving on 'slave_1'
-> [  0.851529] (2:basic.Forwarder@Jackson) Sending "Task_0" to "slave_7"
-> [  2.208640] (3:basic.Forwarder@Casavant) Sending "Task_1" to "slave_9"
-> [  2.720598] (11:basic.Slave@Sirois) Received "Task_1". Processing it.
-> [  3.554211] (9:basic.Slave@Stephen) Received "Task_0". Processing it.
-> [  5.252532] (4:basic.Slave@iRMX) Received "Task_2". Processing it.
-> [  6.267288] (5:basic.Slave@Bousquet) Received "Task_3". Processing it.
-> [  7.711085] (1:basic.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
-> [  7.711085] (6:basic.Slave@Soucy) Received "Task_4". Processing it.
-> [  8.562549] (2:basic.Forwarder@Jackson) Got a finalize task. Let's forward that we're done.
-> [  9.919556] (3:basic.Forwarder@Casavant) Got a finalize task. Let's forward that we're done.
-> [ 10.431474] (11:basic.Slave@Sirois) Received Finalize. I'm done. See you!
-> [ 11.265023] (9:basic.Slave@Stephen) Received Finalize. I'm done. See you!
-> [ 11.318960] (12:basic.Slave@Monique) Received Finalize. I'm done. See you!
-> [ 11.318960] (3:basic.Forwarder@Casavant) I'm done. See you!
-> [ 12.963214] (4:basic.Slave@iRMX) Received Finalize. I'm done. See you!
-> [ 13.908112] (10:basic.Slave@Robert) Received Finalize. I'm done. See you!
-> [ 13.908112] (2:basic.Forwarder@Jackson) I'm done. See you!
-> [ 13.977892] (5:basic.Slave@Bousquet) Received Finalize. I'm done. See you!
-> [ 15.421578] (6:basic.Slave@Soucy) Received Finalize. I'm done. See you!
-> [ 16.278886] (7:basic.Slave@Kuenning) Received Finalize. I'm done. See you!
-> [ 17.252217] (0:@) Done running MSG_MAIN
-> [ 17.252217] (0:@) MSG_main finished
-> [ 17.252217] (0:@) Clean java world
-> [ 17.252217] (0:@) Clean native world
-> [ 17.252217] (1:basic.Master@Jacquelin) Goodbye now!
-> [ 17.252217] (8:basic.Slave@Browne) Received Finalize. I'm done. See you!
\ No newline at end of file
diff --git a/examples/basic/deploy.xml b/examples/basic/deploy.xml
deleted file mode 100644 (file)
index f1351dc..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
-  <!-- The master process (with some arguments) -->
-
-  <process host="Jacquelin" function="basic.Master">
-     <argument value="10"/>       <!-- Number of tasks -->
-     <argument value="50000000"/>  <!-- Computation size of tasks -->
-     <argument value="1000000"/>   <!-- Communication size of tasks -->
-     <argument value="2"/>  <!-- Number of slaves -->
-  </process>
-  <!-- The slave process (with no argument) -->
-  <process host="Jacquelin" function="basic.Slave"><argument value="0"/></process>
-  <process host="Boivin" function="basic.Slave" start_time="5"><argument value="1"/></process>
-<!--  <process host="Jean_Yves" function="Slave"><argument value="2"/></process>
-  <process host="TeX" function="Slave"><argument value="3"/></process>
-  <process host="Geoff" function="Slave"><argument value="4"/></process>
-  <process host="Disney" function="Slave"><argument value="5"/></process>
-  <process host="iRMX" function="Slave"><argument value="6"/></process>
-  <process host="McGee" function="Slave"><argument value="7"/></process>
-  <process host="Gatien" function="Slave"><argument value="8"/></process>
-  <process host="Laroche" function="Slave"><argument value="9"/></process>
-  <process host="Tanguay" function="Slave"><argument value="10"/></process>
-  <process host="Morin" function="Slave"><argument value="11"/></process>
-  <process host="Ethernet" function="Slave"><argument value="12"/></process>
-  <process host="Bellemarre" function="Slave"><argument value="13"/></process>
-  <process host="Kuenning" function="Slave"><argument value="14"/></process>
-  <process host="Gaston" function="Slave"><argument value="15"/></process>
-  <process host="Harry" function="Slave"><argument value="16"/></process>
-  <process host="Bousquet" function="Slave"><argument value="17"/></process>
-  <process host="Paul" function="Slave"><argument value="18"/></process>
-  <process host="St_Jean" function="Slave"><argument value="19"/></process>
-  <process host="Jill" function="Slave"><argument value="20"/></process>
-  <process host="Marcel" function="Slave"><argument value="21"/></process>
-  <process host="Wright" function="Slave"><argument value="22"/></process>
-  <process host="Jackson" function="Slave"><argument value="23"/></process>
-  <process host="Fernand" function="Slave"><argument value="24"/></process>
-  <process host="Soucy" function="Slave"><argument value="25"/></process>
-  <process host="Ste_Julie" function="Slave"><argument value="26"/></process>
-  <process host="Victoria" function="Slave"><argument value="27"/></process>
-  <process host="Lessard" function="Slave"><argument value="28"/></process>
-  <process host="Florient" function="Slave"><argument value="29"/></process>
-  <process host="Marcoux" function="Slave"><argument value="30"/></process>
-  <process host="Gavrel" function="Slave"><argument value="31"/></process>
-  <process host="Bescherelle" function="Slave"><argument value="32"/></process>
-  <process host="Pierre" function="Slave"><argument value="33"/></process>
-  <process host="Jamie" function="Slave"><argument value="34"/></process>
-  <process host="Rubin" function="Slave"><argument value="35"/></process>
-  <process host="Olivier" function="Slave"><argument value="36"/></process>
-  <process host="Boucherville" function="Slave"><argument value="37"/></process>
-  <process host="Pointe_Claire" function="Slave"><argument value="38"/></process>
-  <process host="Kansas" function="Slave"><argument value="39"/></process>
-  <process host="King" function="Slave"><argument value="40"/></process>
-  <process host="Lapointe" function="Slave"><argument value="41"/></process>
-  <process host="Julian" function="Slave"><argument value="42"/></process>
-  <process host="Lafontaine" function="Slave"><argument value="43"/></process>
-  <process host="Gordon" function="Slave"><argument value="44"/></process>
-  <process host="Drouin" function="Slave"><argument value="45"/></process>
-  <process host="Robert" function="Slave"><argument value="46"/></process>
-  <process host="Jocelyne" function="Slave"><argument value="47"/></process>
-  <process host="Stephen" function="Slave"><argument value="48"/></process>
-  <process host="Provost" function="Slave"><argument value="49"/></process>
-  <process host="Juneau" function="Slave"><argument value="50"/></process>
-  <process host="Casavant" function="Slave"><argument value="51"/></process>
-  <process host="St_Antoine" function="Slave"><argument value="52"/></process>
-  <process host="Louis" function="Slave"><argument value="53"/></process>
-  <process host="Julien" function="Slave"><argument value="54"/></process>
-  <process host="St_Paul" function="Slave"><argument value="55"/></process>
-  <process host="Mathematica" function="Slave"><argument value="56"/></process>
-  <process host="LaTeX" function="Slave"><argument value="57"/></process>
-  <process host="Sirois" function="Slave"><argument value="58"/></process>
-  <process host="Monique" function="Slave"><argument value="59"/></process>
-  <process host="Audy" function="Slave"><argument value="60"/></process>
-  <process host="Bourassa" function="Slave"><argument value="61"/></process>
-  <process host="OHara" function="Slave"><argument value="62"/></process>
-  <process host="Boston" function="Slave"><argument value="63"/></process>
-  <process host="Papineau" function="Slave"><argument value="64"/></process>
-  <process host="Fraser" function="Slave"><argument value="65"/></process>
-  <process host="Browne" function="Slave"><argument value="66"/></process>
-  <process host="SunOS" function="Slave"><argument value="67"/></process>
-  <process host="Varennes" function="Slave"><argument value="68"/></process>
-  <process host="Jacques" function="Slave"><argument value="69"/></process>
-  <process host="Thierry" function="Slave"><argument value="70"/></process>
-  <process host="Lachapelle" function="Slave"><argument value="71"/></process>
-  <process host="kV" function="Slave"><argument value="72"/></process>
-  <process host="Yolande" function="Slave"><argument value="73"/></process>
-  <process host="Pronovost" function="Slave"><argument value="74"/></process>
-  <process host="SPICE" function="Slave"><argument value="75"/></process>
-  <process host="Europe" function="Slave"><argument value="76"/></process>
-  <process host="Roy" function="Slave"><argument value="77"/></process>
-  <process host="Amadeus" function="Slave"><argument value="78"/></process>
-  <process host="Intel" function="Slave"><argument value="79"/></process>
-  <process host="Cambridge" function="Slave"><argument value="80"/></process>
-  <process host="Tremblay" function="Slave"><argument value="81"/></process>
-  <process host="UNIX" function="Slave"><argument value="82"/></process>
-  <process host="Domey" function="Slave"><argument value="83"/></process>
-  <process host="St_Bruno" function="Slave"><argument value="84"/></process>
-  <process host="Jean_Claude" function="Slave"><argument value="85"/></process>
-  <process host="Doyon" function="Slave"><argument value="86"/></process>
-  <process host="Fafard" function="Slave"><argument value="87"/></process>
-  <process host="Croteau" function="Slave"><argument value="88"/></process>
-  <process host="Dodge" function="Slave"><argument value="89"/></process>
-  <process host="Jacquelin" function="Slave"><argument value="90"/></process>
-  <process host="Boivin" function="Slave"><argument value="91"/></process>
-  <process host="Jean_Yves" function="Slave"><argument value="92"/></process>
-  <process host="TeX" function="Slave"><argument value="93"/></process>
-  <process host="Geoff" function="Slave"><argument value="94"/></process>
-  <process host="Disney" function="Slave"><argument value="95"/></process>
-  <process host="iRMX" function="Slave"><argument value="96"/></process>
-  <process host="McGee" function="Slave"><argument value="97"/></process>
-  <process host="Gatien" function="Slave"><argument value="98"/></process>
-  <process host="Laroche" function="Slave"><argument value="99"/></process>
-  <process host="Tanguay" function="Slave"><argument value="100"/></process> -->
-</platform>
index 310c6e6..776a31b 100644 (file)
@@ -26,4 +26,4 @@
                                <link_ctn id="3"/>
    </route>
 </AS>
-</platform>
\ No newline at end of file
+</platform>
similarity index 93%
rename from examples/basic/FinalizeTask.java
rename to examples/masterslave/FinalizeTask.java
index 7034e4c..c95e455 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. 
  */
 
-package basic;
+package masterslave;
 import org.simgrid.msg.Task;
 
 public class FinalizeTask extends Task {       
@@ -13,4 +13,4 @@ public class FinalizeTask extends Task {
       super("finalize",0,0);
    }
 }
-    
\ No newline at end of file
+    
similarity index 98%
rename from examples/basic/Forwarder.java
rename to examples/masterslave/Forwarder.java
index e8faf39..0c285ee 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. 
  */
 
-package basic;
+package masterslave;
 
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
similarity index 98%
rename from examples/basic/Master.java
rename to examples/masterslave/Master.java
index dfb4a9b..9d582cf 100644 (file)
@@ -7,7 +7,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. 
  */
 
-package basic;
+package masterslave;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
diff --git a/examples/masterslave/Masterslave.java b/examples/masterslave/Masterslave.java
new file mode 100644 (file)
index 0000000..03acdc6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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. 
+ */
+
+package masterslave;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+
+public class Masterslave {
+   
+   /* This only contains the launcher. If you do nothing more than than you can run 
+    *   java simgrid.msg.Msg
+    * which also contains such a launcher
+    */
+   
+    public static void main(String[] args) throws NativeException {       
+           /* initialize the MSG simulation. Must be done before anything else (even logging). */
+           Msg.init(args);
+       
+           if (args.length < 2) {              
+                       Msg.info("Usage   : Masterslave platform_file deployment_file");
+                       Msg.info("example : Masterslave basic_platform.xml basic_deployment.xml");
+                       System.exit(1); 
+               }
+               /* construct the platform and deploy the application */
+               Msg.createEnvironment(args[0]);
+               Msg.deployApplication(args[1]);
+               /*  execute the simulation. */
+        Msg.run();
+    }
+}
similarity index 98%
rename from examples/basic/Slave.java
rename to examples/masterslave/Slave.java
index dc216a4..e72b76d 100644 (file)
@@ -4,7 +4,7 @@
  * 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. 
  */
-package basic;
+package masterslave;
 
 import org.simgrid.msg.Host;
 import org.simgrid.msg.HostFailureException;
@@ -45,4 +45,4 @@ public class Slave extends Process {
 
                Msg.info("Received Finalize. I'm done. See you!");
        }
-}
\ No newline at end of file
+}
diff --git a/examples/masterslave/deploy.xml b/examples/masterslave/deploy.xml
new file mode 100644 (file)
index 0000000..f72a8b9
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <!-- The master process (with some arguments) -->
+
+  <process host="Jacquelin" function="mastermasterslave.Slave.Master">
+     <argument value="10"/>       <!-- Number of tasks -->
+     <argument value="50000000"/>  <!-- Computation size of tasks -->
+     <argument value="1000000"/>   <!-- Communication size of tasks -->
+     <argument value="2"/>  <!-- Number of masterslave.Slaves -->
+  </process>
+  <!-- The masterslave.Slave process (with no argument) -->
+  <process host="Jacquelin" function="masterslave.Slave"><argument value="0"/></process>
+  <process host="Boivin" function="masterslave.Slave" start_time="5"><argument value="1"/></process>
+<!--  <process host="Jean_Yves" function="masterslave.Slave"><argument value="2"/></process>
+  <process host="TeX" function="masterslave.Slave"><argument value="3"/></process>
+  <process host="Geoff" function="masterslave.Slave"><argument value="4"/></process>
+  <process host="Disney" function="masterslave.Slave"><argument value="5"/></process>
+  <process host="iRMX" function="masterslave.Slave"><argument value="6"/></process>
+  <process host="McGee" function="masterslave.Slave"><argument value="7"/></process>
+  <process host="Gatien" function="masterslave.Slave"><argument value="8"/></process>
+  <process host="Laroche" function="masterslave.Slave"><argument value="9"/></process>
+  <process host="Tanguay" function="masterslave.Slave"><argument value="10"/></process>
+  <process host="Morin" function="masterslave.Slave"><argument value="11"/></process>
+  <process host="Ethernet" function="masterslave.Slave"><argument value="12"/></process>
+  <process host="Bellemarre" function="masterslave.Slave"><argument value="13"/></process>
+  <process host="Kuenning" function="masterslave.Slave"><argument value="14"/></process>
+  <process host="Gaston" function="masterslave.Slave"><argument value="15"/></process>
+  <process host="Harry" function="masterslave.Slave"><argument value="16"/></process>
+  <process host="Bousquet" function="masterslave.Slave"><argument value="17"/></process>
+  <process host="Paul" function="masterslave.Slave"><argument value="18"/></process>
+  <process host="St_Jean" function="masterslave.Slave"><argument value="19"/></process>
+  <process host="Jill" function="masterslave.Slave"><argument value="20"/></process>
+  <process host="Marcel" function="masterslave.Slave"><argument value="21"/></process>
+  <process host="Wright" function="masterslave.Slave"><argument value="22"/></process>
+  <process host="Jackson" function="masterslave.Slave"><argument value="23"/></process>
+  <process host="Fernand" function="masterslave.Slave"><argument value="24"/></process>
+  <process host="Soucy" function="masterslave.Slave"><argument value="25"/></process>
+  <process host="Ste_Julie" function="masterslave.Slave"><argument value="26"/></process>
+  <process host="Victoria" function="masterslave.Slave"><argument value="27"/></process>
+  <process host="Lessard" function="masterslave.Slave"><argument value="28"/></process>
+  <process host="Florient" function="masterslave.Slave"><argument value="29"/></process>
+  <process host="Marcoux" function="masterslave.Slave"><argument value="30"/></process>
+  <process host="Gavrel" function="masterslave.Slave"><argument value="31"/></process>
+  <process host="Bescherelle" function="masterslave.Slave"><argument value="32"/></process>
+  <process host="Pierre" function="masterslave.Slave"><argument value="33"/></process>
+  <process host="Jamie" function="masterslave.Slave"><argument value="34"/></process>
+  <process host="Rubin" function="masterslave.Slave"><argument value="35"/></process>
+  <process host="Olivier" function="masterslave.Slave"><argument value="36"/></process>
+  <process host="Boucherville" function="masterslave.Slave"><argument value="37"/></process>
+  <process host="Pointe_Claire" function="masterslave.Slave"><argument value="38"/></process>
+  <process host="Kansas" function="masterslave.Slave"><argument value="39"/></process>
+  <process host="King" function="masterslave.Slave"><argument value="40"/></process>
+  <process host="Lapointe" function="masterslave.Slave"><argument value="41"/></process>
+  <process host="Julian" function="masterslave.Slave"><argument value="42"/></process>
+  <process host="Lafontaine" function="masterslave.Slave"><argument value="43"/></process>
+  <process host="Gordon" function="masterslave.Slave"><argument value="44"/></process>
+  <process host="Drouin" function="masterslave.Slave"><argument value="45"/></process>
+  <process host="Robert" function="masterslave.Slave"><argument value="46"/></process>
+  <process host="Jocelyne" function="masterslave.Slave"><argument value="47"/></process>
+  <process host="Stephen" function="masterslave.Slave"><argument value="48"/></process>
+  <process host="Provost" function="masterslave.Slave"><argument value="49"/></process>
+  <process host="Juneau" function="masterslave.Slave"><argument value="50"/></process>
+  <process host="Casavant" function="masterslave.Slave"><argument value="51"/></process>
+  <process host="St_Antoine" function="masterslave.Slave"><argument value="52"/></process>
+  <process host="Louis" function="masterslave.Slave"><argument value="53"/></process>
+  <process host="Julien" function="masterslave.Slave"><argument value="54"/></process>
+  <process host="St_Paul" function="masterslave.Slave"><argument value="55"/></process>
+  <process host="Mathematica" function="masterslave.Slave"><argument value="56"/></process>
+  <process host="LaTeX" function="masterslave.Slave"><argument value="57"/></process>
+  <process host="Sirois" function="masterslave.Slave"><argument value="58"/></process>
+  <process host="Monique" function="masterslave.Slave"><argument value="59"/></process>
+  <process host="Audy" function="masterslave.Slave"><argument value="60"/></process>
+  <process host="Bourassa" function="masterslave.Slave"><argument value="61"/></process>
+  <process host="OHara" function="masterslave.Slave"><argument value="62"/></process>
+  <process host="Boston" function="masterslave.Slave"><argument value="63"/></process>
+  <process host="Papineau" function="masterslave.Slave"><argument value="64"/></process>
+  <process host="Fraser" function="masterslave.Slave"><argument value="65"/></process>
+  <process host="Browne" function="masterslave.Slave"><argument value="66"/></process>
+  <process host="SunOS" function="masterslave.Slave"><argument value="67"/></process>
+  <process host="Varennes" function="masterslave.Slave"><argument value="68"/></process>
+  <process host="Jacques" function="masterslave.Slave"><argument value="69"/></process>
+  <process host="Thierry" function="masterslave.Slave"><argument value="70"/></process>
+  <process host="Lachapelle" function="masterslave.Slave"><argument value="71"/></process>
+  <process host="kV" function="masterslave.Slave"><argument value="72"/></process>
+  <process host="Yolande" function="masterslave.Slave"><argument value="73"/></process>
+  <process host="Pronovost" function="masterslave.Slave"><argument value="74"/></process>
+  <process host="SPICE" function="masterslave.Slave"><argument value="75"/></process>
+  <process host="Europe" function="masterslave.Slave"><argument value="76"/></process>
+  <process host="Roy" function="masterslave.Slave"><argument value="77"/></process>
+  <process host="Amadeus" function="masterslave.Slave"><argument value="78"/></process>
+  <process host="Intel" function="masterslave.Slave"><argument value="79"/></process>
+  <process host="Cambridge" function="masterslave.Slave"><argument value="80"/></process>
+  <process host="Tremblay" function="masterslave.Slave"><argument value="81"/></process>
+  <process host="UNIX" function="masterslave.Slave"><argument value="82"/></process>
+  <process host="Domey" function="masterslave.Slave"><argument value="83"/></process>
+  <process host="St_Bruno" function="masterslave.Slave"><argument value="84"/></process>
+  <process host="Jean_Claude" function="masterslave.Slave"><argument value="85"/></process>
+  <process host="Doyon" function="masterslave.Slave"><argument value="86"/></process>
+  <process host="Fafard" function="masterslave.Slave"><argument value="87"/></process>
+  <process host="Croteau" function="masterslave.Slave"><argument value="88"/></process>
+  <process host="Dodge" function="masterslave.Slave"><argument value="89"/></process>
+  <process host="Jacquelin" function="masterslave.Slave"><argument value="90"/></process>
+  <process host="Boivin" function="masterslave.Slave"><argument value="91"/></process>
+  <process host="Jean_Yves" function="masterslave.Slave"><argument value="92"/></process>
+  <process host="TeX" function="masterslave.Slave"><argument value="93"/></process>
+  <process host="Geoff" function="masterslave.Slave"><argument value="94"/></process>
+  <process host="Disney" function="masterslave.Slave"><argument value="95"/></process>
+  <process host="iRMX" function="masterslave.Slave"><argument value="96"/></process>
+  <process host="McGee" function="masterslave.Slave"><argument value="97"/></process>
+  <process host="Gatien" function="masterslave.Slave"><argument value="98"/></process>
+  <process host="Laroche" function="masterslave.Slave"><argument value="99"/></process>
+  <process host="Tanguay" function="masterslave.Slave"><argument value="100"/></process> -->
+</platform>
diff --git a/examples/masterslave/masterslave.tesh b/examples/masterslave/masterslave.tesh
new file mode 100644 (file)
index 0000000..b13ffaf
--- /dev/null
@@ -0,0 +1,35 @@
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar masterslave/Masterslave ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/masterslave/masterslaveDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Ready to run MSG_MAIN
+> [  0.000000] (1:masterslave.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process
+> [  0.000000] (2:masterslave.Forwarder@Jackson) Receiving on 'slave_0'
+> [  0.000000] (3:masterslave.Forwarder@Casavant) Receiving on 'slave_1'
+> [  0.851529] (2:masterslave.Forwarder@Jackson) Sending "Task_0" to "slave_7"
+> [  2.208640] (3:masterslave.Forwarder@Casavant) Sending "Task_1" to "slave_9"
+> [  2.720598] (11:masterslave.Slave@Sirois) Received "Task_1". Processing it.
+> [  3.554211] (9:masterslave.Slave@Stephen) Received "Task_0". Processing it.
+> [  5.252532] (4:masterslave.Slave@iRMX) Received "Task_2". Processing it.
+> [  6.267288] (5:masterslave.Slave@Bousquet) Received "Task_3". Processing it.
+> [  7.711085] (1:masterslave.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
+> [  7.711085] (6:masterslave.Slave@Soucy) Received "Task_4". Processing it.
+> [  8.562549] (2:masterslave.Forwarder@Jackson) Got a finalize task. Let's forward that we're done.
+> [  9.919556] (3:masterslave.Forwarder@Casavant) Got a finalize task. Let's forward that we're done.
+> [ 10.431474] (11:masterslave.Slave@Sirois) Received Finalize. I'm done. See you!
+> [ 11.265023] (9:masterslave.Slave@Stephen) Received Finalize. I'm done. See you!
+> [ 11.318960] (12:masterslave.Slave@Monique) Received Finalize. I'm done. See you!
+> [ 11.318960] (3:masterslave.Forwarder@Casavant) I'm done. See you!
+> [ 12.963214] (4:masterslave.Slave@iRMX) Received Finalize. I'm done. See you!
+> [ 13.908112] (10:masterslave.Slave@Robert) Received Finalize. I'm done. See you!
+> [ 13.908112] (2:masterslave.Forwarder@Jackson) I'm done. See you!
+> [ 13.977892] (5:masterslave.Slave@Bousquet) Received Finalize. I'm done. See you!
+> [ 15.421578] (6:masterslave.Slave@Soucy) Received Finalize. I'm done. See you!
+> [ 16.278886] (7:masterslave.Slave@Kuenning) Received Finalize. I'm done. See you!
+> [ 17.252217] (0:@) Done running MSG_MAIN
+> [ 17.252217] (0:@) MSG_main finished
+> [ 17.252217] (0:@) Clean java world
+> [ 17.252217] (0:@) Clean native world
+> [ 17.252217] (1:masterslave.Master@Jacquelin) Goodbye now!
+> [ 17.252217] (8:masterslave.Slave@Browne) Received Finalize. I'm done. See you!
similarity index 67%
rename from examples/basic/basicDeployment.xml
rename to examples/masterslave/masterslaveDeployment.xml
index 7edfa6d..6c01ac0 100644 (file)
@@ -1,49 +1,49 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
-  <process host="Jacquelin" function="basic.Master">
+  <process host="Jacquelin" function="masterslave.Master">
      <argument value="5"/>     <!-- Amount of tasks to dispatch -->
      <argument value="50000"/> <!-- Computation size of each task -->
      <argument value="10"/>    <!-- Communication size of each one -->
      <argument value="7"/>     <!-- Amount of slaves waiting for orders -->
   </process>
   
-  <process host="Jackson" function="basic.Forwarder">
+  <process host="Jackson" function="masterslave.Forwarder">
      <argument value="0"/>  <!-- Input mailbox -->
      <argument value="7"/>  <!-- First output mailbox -->
      <argument value="8"/>  <!-- Last output mailbox -->
   </process>
-  <process host="Casavant" function="basic.Forwarder">
+  <process host="Casavant" function="masterslave.Forwarder">
      <argument value="1"/>  <!-- Input mailbox -->
      <argument value="9"/>  <!-- First output mailbox -->
      <argument value="10"/> <!-- Last output mailbox -->
   </process>
   
-  <process host="iRMX" function="basic.Slave">
+  <process host="iRMX" function="masterslave.Slave">
      <argument value="2"/>  <!-- Input mailbox -->
   </process>
-  <process host="Bousquet" function="basic.Slave">
+  <process host="Bousquet" function="masterslave.Slave">
      <argument value="3"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Soucy" function="basic.Slave">
+  <process host="Soucy" function="masterslave.Slave">
      <argument value="4"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Kuenning" function="basic.Slave">
+  <process host="Kuenning" function="masterslave.Slave">
      <argument value="5"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Browne" function="basic.Slave">
+  <process host="Browne" function="masterslave.Slave">
      <argument value="6"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Stephen" function="basic.Slave">
+  <process host="Stephen" function="masterslave.Slave">
      <argument value="7"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Robert" function="basic.Slave">
+  <process host="Robert" function="masterslave.Slave">
      <argument value="8"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Sirois" function="basic.Slave">
+  <process host="Sirois" function="masterslave.Slave">
      <argument value="9"/>  <!-- Input mailbox -->
   </process>  
-  <process host="Monique" function="basic.Slave">
+  <process host="Monique" function="masterslave.Slave">
      <argument value="10"/>  <!-- Input mailbox -->
   </process>  
 </platform>
diff --git a/examples/migration/Emigrant.java b/examples/migration/Emigrant.java
new file mode 100644 (file)
index 0000000..c875081
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 2012. 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. 
+ */
+package migration;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Emigrant extends Process {
+       public Emigrant(Host host, String name, String[]args) {
+               super(host,name,args);
+       }
+       public void main(String[] args) throws MsgException {           
+               Migration.mutex.acquire();
+               
+               Msg.info("I'll look for a new job on another machine where the grass is greener.");
+               migrate(Host.getByName("Boivin"));
+               
+               Msg.info("Yeah, found something to do");
+               Task task = new Task("job", 98095000, 0);
+               task.execute();
+               waitFor(2);
+               
+               Msg.info("Moving back to home after work");
+               migrate(Host.getByName("Jacquelin"));
+               migrate(Host.getByName("Boivin"));
+               waitFor(4);
+               
+               Migration.processToMigrate = this;
+               Migration.mutex.release();              
+               suspend();
+                       
+               Msg.info("I've been moved on this new host:" + getHost().getName());
+               Msg.info("Uh, nothing to do here. Stopping now");
+       }
+}
\ No newline at end of file
diff --git a/examples/migration/Migration.java b/examples/migration/Migration.java
new file mode 100644 (file)
index 0000000..bcf17ab
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * $Id$
+ *
+ * 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. 
+ */
+package migration;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Mutex;
+import org.simgrid.msg.NativeException;
+import org.simgrid.msg.Process;
+/**
+ * Demonstrates the use of Task.setPriority to change
+ * the computation priority of a task
+ */ 
+public class Migration  {
+       public static Mutex mutex;
+       public static Process processToMigrate = null;
+       
+   /* This only contains the launcher. If you do nothing more than than you can run 
+    *   java simgrid.msg.Msg
+    * which also contains such a launcher
+    */
+    
+    public static void main(String[] args) throws NativeException {            
+               /* initialize the MSG simulation. Must be done before anything else (even logging). */
+               Msg.init(args);
+               if(args.length < 2) {
+                       Msg.info("Usage   : Priority platform_file deployment_file");
+               Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml");
+               System.exit(1);
+               }
+               /* Create the mutex */
+               mutex = new Mutex();            
+               
+               /* construct the platform and deploy the application */
+               Msg.createEnvironment(args[0]);
+               Msg.deployApplication(args[1]);
+               
+               /*  execute the simulation. */
+           Msg.run();
+    }
+}
diff --git a/examples/migration/Policeman.java b/examples/migration/Policeman.java
new file mode 100644 (file)
index 0000000..3e01db3
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 2012. 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. 
+ */
+package migration;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Policeman extends Process {
+       public Policeman(Host host, String name, String[]args) {
+               super(host,name,args);
+       }
+
+       @Override
+       public void main(String[] args) throws MsgException {
+               waitFor(1);
+               
+               Msg.info("Wait a bit before migrating the emigrant.");
+               
+               Migration.mutex.acquire();
+               
+               Migration.processToMigrate.migrate(Host.getByName("Jacquelin"));
+               Msg.info("I moved the emigrant");
+               Migration.processToMigrate.resume();
+       }
+}
\ No newline at end of file
diff --git a/examples/migration/migration.tesh b/examples/migration/migration.tesh
new file mode 100644 (file)
index 0000000..869acc5
--- /dev/null
@@ -0,0 +1,18 @@
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar migration/Migration ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/migration/migrationDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Ready to run MSG_MAIN
+> [  0.000000] (1:migration.Emigrant@Jacquelin) I'll look for a new job on another machine where the grass is greener.
+> [  0.000000] (1:migration.Emigrant@Boivin) Yeah, found something to do
+> [  1.000000] (2:migration.Policeman@Boivin) Wait a bit before migrating the emigrant.
+> [  3.000000] (1:migration.Emigrant@Boivin) Moving back to home after work
+> [  7.000000] (0:@) Done running MSG_MAIN
+> [  7.000000] (0:@) MSG_main finished
+> [  7.000000] (0:@) Clean java world
+> [  7.000000] (0:@) Clean native world
+> [  7.000000] (1:migration.Emigrant@Jacquelin) I've been moved on this new host:Jacquelin
+> [  7.000000] (1:migration.Emigrant@Jacquelin) Uh, nothing to do here. Stopping now
+> [  7.000000] (2:migration.Policeman@Boivin) I moved the emigrant
+
diff --git a/examples/migration/migrationDeployment.xml b/examples/migration/migrationDeployment.xml
new file mode 100644 (file)
index 0000000..db7c6c0
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Jacquelin" function="migration.Emigrant"/>
+  <process host="Boivin" function="migration.Policeman"/>
+</platform>
index 2f1efe5..f3bb90d 100644 (file)
@@ -15,7 +15,7 @@ public class DreamMaster extends Process {
                Msg.info("Let's wait a little bit...");
                waitFor(10);
                Msg.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
-               lazyGuy.restart();
+               lazyGuy.resume();
                Msg.info("OK, goodbye now.");
        }
 }
\ No newline at end of file
index cb7c722..0904636 100644 (file)
@@ -10,7 +10,7 @@ public class LazyGuy extends Process {
        } 
        public void main(String[] args) throws MsgException {
                Msg.info("Nobody's watching me ? Let's go to sleep.");
-               pause();
+               suspend();
                Msg.info("Uuuh ? Did somebody call me ?");
                Msg.info("Mmmh, goodbye now.");
        }
index 083aa4a..fb9bcf3 100644 (file)
@@ -12,7 +12,7 @@
 package org.simgrid.msg;
 
 /**
- * This exception is raised when The host on which you are running has just been rebooted.
+ * This exception is raised when the host on which you are running has just been rebooted.
  */
 public class HostFailureException extends MsgException {
        private static final long serialVersionUID = 1L;
index a4db8be..c2b9cd7 100644 (file)
@@ -24,28 +24,6 @@ public final class Msg {
                        System.exit(1);
                }
        }
-
-       /** Everything is right. Keep on going the way ! */
-       public static final int SUCCESS = 0;
-
-       /** Something must be not perfectly clean (but I may be paranoid freak...) */
-       public static final int WARNING = 1;
-
-       /** There has been a problem during your task transfer.
-        *  Either the network is  down or the remote host has been shutdown */
-       public static final int TRANSFERT_FAILURE = 2;
-
-       /** System shutdown. 
-        *  The host on which you are running has just been rebooted.
-        *  Free your data structures and return now ! */
-       public static final int HOST_FAILURE = 3;
-
-       /** Canceled task. This task has been canceled by somebody ! */
-       public static final int TASK_CANCELLLED = 4;
-
-       /** You've done something wrong. You'd better look at it... */
-       public static final int FATAL_ERROR = 5;
-
     /** Retrieve the simulation time
      * @return
      */
index b88e4d2..7032b6e 100644 (file)
@@ -1,8 +1,4 @@
-package org.simgrid.msg;
-/** A mutex  implemented on top of SimGrid synchronization mechanisms. 
- * You can use it exactly the same way that you use the mutexes, 
- * but to handle the interactions between the threads within the simulation.   
- * 
+/* 
  * Copyright 2012 The SimGrid team. All right reserved. 
  *
  * This program is free software; you can redistribute 
@@ -10,17 +6,23 @@ package org.simgrid.msg;
  * (GNU LGPL) which comes with this package.
  *
  */
+package org.simgrid.msg;
+/** A mutex  implemented on top of SimGrid synchronization mechanisms. 
+ * You can use it exactly the same way that you use the mutexes, 
+ * but to handle the interactions between the processes within the simulation.   
+ *
+ */
 public class Mutex {
        private long bind; // The C object -- don't touch it
        
-       public Mutex(int capa) {
-               init(capa);
+       public Mutex() {
+               init();
        }
        protected void finalize() {
                exit();
        }
        private native void exit();
-       private native void init(int capacity);
+       private native void init();
        public native void acquire();
        public native void release();
        
index f9572c5..714a7a3 100644 (file)
@@ -230,16 +230,31 @@ public abstract class Process implements Runnable {
        /**
         * Suspends the process by suspending the task on which it was
         * waiting for the completion.
-        *
         */
-       public native void pause();
+       public native void suspend();
+       /**
+        * Suspends the process by suspending the task on which it was
+        * waiting for the completion.
+        * DEPRECATED: use suspend instead.
+        */
+       @Deprecated
+       public void pause() {
+               suspend();
+       }
        /**
         * Resumes a suspended process by resuming the task on which it was
         * waiting for the completion.
-        *
-        *
+        * DEPRECATED: use resume instead.
         */ 
-       public native void restart();
+       @Deprecated
+       public void restart() {
+               resume();
+       }
+       /**
+        * Resumes a suspended process by resuming the task on which it was
+        * waiting for the completion.
+        */
+       public native void resume();    
        /**
         * Tests if a process is suspended.
         *
@@ -308,7 +323,7 @@ public abstract class Process implements Runnable {
         * @param host                  The host where to migrate the process.
         *
         */
-       public native static void migrate(Process process, Host host);  
+       public native void migrate(Host host);  
        /**
         * Makes the current process sleep until millis millisecondes have elapsed.
         * You should note that unlike "waitFor" which takes seconds, this method takes milliseconds.
index 6cd1c4a..56dcb87 100644 (file)
@@ -1,7 +1,9 @@
 package org.simgrid.msg;
 
-/** This exception class is only used to interrupt the java user code 
- * when the process gets killed by an external event */
+/** This error class is only used to interrupt the java user code 
+ * when the process gets killed by an external event.
+ * Don't catch it.
+ */
 
 public class ProcessKilledError extends Error {
        private static final long serialVersionUID = 1L;
index 78c88dc..dc3d262 100644 (file)
@@ -216,7 +216,7 @@ Java_org_simgrid_msg_Process_currentProcess(JNIEnv * env, jclass cls)
 }
 
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_pause(JNIEnv * env,
+Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
                                    jobject jprocess)
 {
   m_process_t process = jprocess_to_native_process(jprocess, env);
@@ -234,7 +234,7 @@ Java_org_simgrid_msg_Process_pause(JNIEnv * env,
 
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_restart(JNIEnv * env,
+Java_org_simgrid_msg_Process_resume(JNIEnv * env,
                                      jobject jprocess)
 {
   m_process_t process = jprocess_to_native_process(jprocess, env);
index 3866ad9..7d5bead 100644 (file)
@@ -182,18 +182,18 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
     (JNIEnv *, jclass);
 /*
  * Class               org_simgrid_msg_Process
- * Method              pause
+ * Method              suspend
  * Signature   (Lorg/simgrid/msg/Process;)V
  */
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_pause(JNIEnv * env,
+Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
                                           jobject jprocess);
 /*
  * Class               org_simgrid_msg_Process
- * Method              restart
+ * Method              resume
  * Signature   (Lorg/simgrid/msg/Process;)V
  */
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume
     (JNIEnv *, jobject);
 /*
  * Class               org_simgrid_msg_Process
index abffec4..a504026 100644 (file)
@@ -8,6 +8,8 @@
 #include "jmsg_synchro.h"
 #include "jxbt_utilities.h"
 
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
+
 static jfieldID jsyncro_field_Mutex_bind;
 
 JNIEXPORT void JNICALL
index a68ebea..91a3b93 100644 (file)
@@ -138,7 +138,7 @@ void smx_ctx_java_stop(smx_context_t context)
 {
        smx_ctx_java_t ctx_java = (smx_ctx_java_t)context;
   /* I am the current process and I am dying */
-       if (context->iwannadie == -1) {
+       if (context->iwannadie) {
        context->iwannadie = 0;
        JNIEnv *env = get_current_thread_env();
        jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process killed :)"));