Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git://scm.gforge.inria.fr/simgrid/simgrid-java
authoralebre <alebre@noname-2.local>
Tue, 12 Jun 2012 20:44:02 +0000 (22:44 +0200)
committeralebre <alebre@noname-2.local>
Tue, 12 Jun 2012 20:44:02 +0000 (22:44 +0200)
Conflicts:
CMakeLists.txt
ChangeLog

53 files changed:
CMakeLists.txt
ChangeLog
GenerateDoc.cmake
examples/async/AsyncTest.java
examples/basic/BasicTest.java [deleted file]
examples/basic/basic.tesh [deleted file]
examples/basic/deploy.xml [deleted file]
examples/io/IO.java [new file with mode: 0644]
examples/io/Node.java [new file with mode: 0644]
examples/io/storage.xml [new file with mode: 0644]
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/priority/Priority.java [new file with mode: 0644]
examples/priority/Test.java [new file with mode: 0644]
examples/priority/priority.tesh [new file with mode: 0644]
examples/priority/priorityDeployment.xml [new file with mode: 0644]
examples/suspend/DreamMaster.java [new file with mode: 0644]
examples/suspend/LazyGuy.java [new file with mode: 0644]
examples/suspend/Suspend.java [new file with mode: 0644]
examples/suspend/suspend.tesh [new file with mode: 0644]
examples/suspend/suspendDeployment.xml [new file with mode: 0644]
org/simgrid/msg/File.java [new file with mode: 0644]
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
org/simgrid/msg/RngStream.java
src/jmsg.c
src/jmsg_file.c [new file with mode: 0644]
src/jmsg_file.h [new file with mode: 0644]
src/jmsg_host.c
src/jmsg_process.c
src/jmsg_process.h
src/jmsg_synchro.c
src/jmsg_task.c
src/smx_context_cojava.c [new file with mode: 0644]
src/smx_context_cojava.h [new file with mode: 0644]
src/smx_context_java.c
src/smx_context_java.h

index 0d64f21..8d9e3bf 100644 (file)
@@ -72,6 +72,8 @@ include(FindJavaSG.cmake)
 # Declare our package content #
 ###############################
 set(JMSG_C_SRC
+       src/smx_context_cojava.h
+       src/smx_context_cojava.c
        src/smx_context_java.h
        src/smx_context_java.c
        src/jxbt_utilities.c
@@ -80,16 +82,18 @@ set(JMSG_C_SRC
        src/jmsg.h
        src/jmsg_comm.c
        src/jmsg_comm.h
+       src/jmsg_file.c
+       src/jmsg_file.h
        src/jmsg_host.c
        src/jmsg_host.h
        src/jmsg_process.c
        src/jmsg_process.h
-       src/jmsg_task.c
-       src/jmsg_task.h
-       src/jmsg_synchro.c
-       src/jmsg_synchro.h
        src/jmsg_rngstream.c
        src/jmsg_rngstream.h
+       src/jmsg_synchro.c
+       src/jmsg_synchro.h
+       src/jmsg_task.c
+       src/jmsg_task.h
 )
 
 set(JTRACE_C_SRC
@@ -101,6 +105,7 @@ set(JMSG_JAVA_SRC
        org/simgrid/msg/Host.java
        org/simgrid/msg/HostFailureException.java       
        org/simgrid/msg/HostNotFoundException.java      
+    org/simgrid/msg/File.java
        org/simgrid/msg/JniException.java
        org/simgrid/msg/Msg.java
        org/simgrid/msg/MsgException.java
@@ -121,6 +126,11 @@ set(JTRACE_JAVA_SRC
 )
 
 set(JAVA_EXAMPLES
+       examples/async/AsyncTest.java
+       examples/async/FinalizeTask.java  
+       examples/async/Forwarder.java
+       examples/async/Master.java  
+       examples/async/Slave.java
   examples/bittorrent/Bittorrent.java
   examples/bittorrent/Common.java
   examples/bittorrent/Connection.java
@@ -136,25 +146,17 @@ set(JAVA_EXAMPLES
        examples/chord/FindSuccessorTask.java
        examples/chord/GetPredecessorAnswerTask.java
        examples/chord/NotifyTask.java
-       examples/mutualExclusion/centralized/MutexCentral.java
-       examples/mutualExclusion/centralized/GrantTask.java
-       examples/mutualExclusion/centralized/Coordinator.java
-       examples/mutualExclusion/centralized/ReleaseTask.java
-       examples/mutualExclusion/centralized/Node.java
-       examples/mutualExclusion/centralized/RequestTask.java
-       examples/basic/FinalizeTask.java
-       examples/basic/Forwarder.java
-       examples/basic/Master.java
-       examples/basic/BasicTest.java
-       examples/basic/Slave.java
        examples/commTime/FinalizeTask.java
        examples/commTime/Master.java
        examples/commTime/Slave.java
        examples/commTime/CommTimeTest.java
-       examples/pingPong/PingPongTask.java
-       examples/pingPong/Sender.java
-       examples/pingPong/Receiver.java
-       examples/pingPong/PingPongTest.java
+       examples/io/IO.java
+       examples/io/Node.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
@@ -163,15 +165,26 @@ set(JAVA_EXAMPLES
        examples/master_slave_kill/MsKill.java
        examples/master_slave_kill/Slave.java
        examples/master_slave_kill/FinalizeTask.java
-       examples/async/AsyncTest.java
-       examples/async/FinalizeTask.java  
-       examples/async/Forwarder.java
-       examples/async/Master.java  
-       examples/async/Slave.java
-       examples/startKillTime/Slave.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
+       examples/mutualExclusion/centralized/ReleaseTask.java
+       examples/mutualExclusion/centralized/Node.java
+       examples/mutualExclusion/centralized/RequestTask.java
+       examples/pingPong/PingPongTask.java
+       examples/pingPong/Sender.java
+       examples/pingPong/Receiver.java
+       examples/pingPong/PingPongTest.java
        examples/startKillTime/Master.java
+       examples/startKillTime/Slave.java
        examples/startKillTime/StartKillTime.java
        examples/tracing/PingPongTask.java
+       examples/suspend/DreamMaster.java
+       examples/suspend/LazyGuy.java
+       examples/suspend/Suspend.java
        examples/tracing/Sender.java
        examples/tracing/Receiver.java
        examples/tracing/TracingTest.java
@@ -185,18 +198,18 @@ ${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/tracing/tracingPingPongDeployment.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
@@ -299,17 +312,23 @@ add_custom_command(
        COMMENT "Build examples for java"
        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/basic/*.java  
-       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/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/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/mutualExclusion/centralized/*.java                                 
+  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/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/io/*.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    
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/tracing/*.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/suspend/*.java
+
 )
 
 add_custom_target(simgrid_java_examples ALL
@@ -333,18 +352,22 @@ 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(chord          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh)
-ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
-ADD_TEST(CommTime        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh)
-ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.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)
 ADD_TEST(tracing         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPong.tesh)
 #Don't forget to put new test in this list!!!
-set(test_list basic bittorrent chord async pingPong CommTime mutualExclusion bypass kill startKillTime tracing)
+#Don't forget to put new test in this list!!!
+set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime tracing)
 
 ##########################################
 # Set the  DYLD_LIBRARY_PATH for mac     #
index 9f4e141..7f6ac28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,21 +6,38 @@ SimGrid-java (3.8) unstable; urgency=low
    few of thems are really implemented at the JNI level (see ./src/jtrace.c
    for further information). 
 
-SimGrid-java (3.6.1) unstable; urgency=low
-
- * Introduce msg.simgrid.Mutex, exporting simgrid mutex to Java.
+SimGrid-java (3.7.1) stable; urgency=low
+  
+ The "Java aint got to be bloated and slow" release
+ Major cleanups:
+ * Various internal cleanups and performance improvement
+   Simulations are expected to run up to twice faster or so
+ * Make Process.kill(process) an instance method, not a static one
+ * User processes are not java.lang.Thread subclasses. 
+   This breaks the compatibility (sorry), but previous API was
+   brain-dead, making it impossible to have non-trivial
+   initializations in the process constructor. 
+ * Require a full constructor per Process sub-class.
+   Kinda breaks the compatibility (sorry), but this allows a much more
+   efficient way to launch the processes at simulation startup.
  * Do not embeed our version of semaphores, java 1.5 can be considered
    as sufficiently prevalent for us to not dupplicate its features.
- * Make Process.kill(process) an instance method, not a static one
- * Fix a bug around Process.kill()
- * Add the asynchronous API to the bindings.
- * Add "sleep" in Process with Thread-like syntax/use.
- * Change the way the Process are created in ApplicationHandler: a full 
-constructor is now needed for your child classes.
- * Change the way Process are created: Process are no longer a Thread subclass.
- -- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
+ * Lot of bug fixes
+ Extend the API:
+ * Add examples for almost every part of the API
+   We spotted and fixed a lot of bugs in the process
+ * New module: asynchronous communication API
+ * New function: Process.sleep()
+   It takes milliseconds as argument, just as java.lang.Thread.sleep()
+ * New module: org.simgrid.msg.Mutex (SimGrid mutexes)
+ * New module: org.simgrid.msg.RngStream (RngStreams random generators)
 
-SimGrid-java (3.6) unstable; urgency=low
+ -- 2012-06-12 Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
+SimGrid-java (1.0 (3.6) unstable; urgency=low
 
  * Initial release.
  * Split of every thing from simgrid v3.5 into a separate package.
index d8c9199..bcd7a7d 100644 (file)
@@ -61,6 +61,7 @@ add_dependencies(pdf simgrid_documentation)
 add_custom_target(sync-gforge-doc
 COMMAND chmod g+rw -R doc/
 COMMAND chmod a+rX -R doc/
+COMMAND ssh scm.gforge.inria.fr mkdir /home/groups/simgrid/htdocs/simgrid-java/${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR} || true 
 COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times 
 doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/simgrid-java/${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR}/doc/ || true
 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
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>
diff --git a/examples/io/IO.java b/examples/io/IO.java
new file mode 100644 (file)
index 0000000..6a6674f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 io;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+/**
+ * This example demonstrates of how to use the other
+ * kind of resources, such as disk or GPU. These resources are quite
+ * experimental for now, but here we go anyway.
+ */
+public class IO {
+    public static void main(String[] args) throws MsgException {       
+               Msg.init(args);
+               if(args.length < 1) {
+                       Msg.info("Usage   : IO platform_file ");
+               Msg.info("example : IO platform.xml ");
+               System.exit(1);
+           }    
+               Msg.createEnvironment(args[0]);
+               
+               Host[] hosts = Host.all();
+               
+               Msg.info("Number of hosts:" + hosts.length);
+               for (int i = 0; i < hosts.length && i < 4; i++) {
+                       new io.Node(hosts[i],i).start();
+               }
+               
+               Msg.run();              
+    }
+}
\ No newline at end of file
diff --git a/examples/io/Node.java b/examples/io/Node.java
new file mode 100644 (file)
index 0000000..5afc600
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 io;
+
+import org.simgrid.msg.File;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+
+public class Node extends Process {
+       private static String FILENAME1 = "/home/user/Install/simgrid/doc/simgrid/examples/platforms/g5k.xml";
+       private static String FILENAME2 = "/home/user/Install/simgrid/doc/simgrid/examples/platforms/One_cluster_no_backbone.xml";
+       private static String FILENAME3 = "/home/user/Install/simgrid/doc/simgrid/examples/platforms/g5k_cabinets.xml";
+       private static String FILENAME4 = "/home/user/Install/simgrid/doc/simgrid/examples/platforms/nancy.xml";
+                       
+       protected int number;
+               
+       public Node(Host host, int number) throws HostNotFoundException {
+               super(host, Integer.toString(number), null);
+               this.number = number;
+       }       
+       public void main(String[] args) throws MsgException {
+               String mount = "C:";
+               String filename;
+               switch (number) {
+                       case 0:
+                               filename = FILENAME1;
+                       break;
+                       case 1:
+                               filename = FILENAME2;
+                       break;
+                       case 2:
+                               filename = FILENAME3;
+                       break;
+                       case 3:
+                               filename = FILENAME4;
+                       break;
+                       default:
+                               filename = FILENAME1;
+               }
+               Msg.info("Open file " + filename);
+               File file = new File(mount,filename, "rw");
+
+               long read = file.read(mount,10000000,1);
+               Msg.info("Having read " + read + " on " + filename);
+               
+               long write = file.read(mount,100000,1);
+               Msg.info("Having write " + write + " on " + filename);
+
+               read = file.read(mount,10000000,1);
+               Msg.info("Having read " + read + " on " + filename);            
+       }
+}
\ No newline at end of file
diff --git a/examples/io/storage.xml b/examples/io/storage.xml
new file mode 100644 (file)
index 0000000..58fca89
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+
+<platform version="3">
+
+       <AS id="AS0" routing="Full">
+
+               <storage_type id="samsung" model="RAID5" content="content/storage_content.txt" size="500">
+                       <prop id="Bwrite" value="30000000" /> <!-- 30Mo/s -->
+                       <prop id="Bread" value="100000000" /> <!-- 100Mo/s -->
+                       <prop id="Bconnection" value="150000000" /> <!-- 150Mo/s -->
+               </storage_type>
+
+               <storage_type id="crucial" model="SSD" content="content/storage_content.txt" size="500">
+                       <prop id="Bwrite" value="30000000" />
+                       <prop id="Bread" value="100000000" />
+                       <prop id="Bconnection" value="150000000" />
+               </storage_type>
+
+               <storage_type id="wdigital" model="RAID0" content="content/storage_content.txt" size="500">
+                       <prop id="Bwrite" value="30000000" />
+                       <prop id="Bread" value="100000000" />
+                       <prop id="Bconnection" value="150000000" />
+               </storage_type>
+
+               <storage id="Disk1" typeId="crucial"/>
+               <storage id="Disk2" typeId="samsung"/>
+               <storage id="Disk3" typeId="wdigital"/>
+               <storage id="Disk4" typeId="wdigital"/>
+
+               <host id="bob" power="1000000000">
+                       <mount id="Disk1" name="C:"/>                   
+               </host>         
+               
+               <host id="alice" power="1000000000">
+                       <mount id="Disk2" name="C:"/>
+               </host>
+
+               <host id="carl" power="1000000000">             
+                       <mount id="Disk3" name="C:"/>           
+               </host>
+               
+               <host id="denise" power="1000000000">
+                       <mount id="Disk4" name="C:"/>   
+               </host>
+
+               <link id="link1" bandwidth="125000000" latency="5E-5" />
+               <link id="link2" bandwidth="125000000" latency="5E-5" />
+               <link id="link3" bandwidth="125000000" latency="5E-5" />
+       
+               <route src="bob" dst="alice" symmetrical="YES">
+                       <link_ctn id="link1" />
+                       <link_ctn id="link2" />
+                       <link_ctn id="link3" />
+               </route>        
+
+       </AS>
+</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>
diff --git a/examples/priority/Priority.java b/examples/priority/Priority.java
new file mode 100644 (file)
index 0000000..e5bcfb7
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * $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 priority;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+/**
+ * Demonstrates the use of Task.setPriority to change
+ * the computation priority of a task
+ */ 
+public class Priority  {
+
+   /* 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);
+               }
+       
+               /* construct the platform and deploy the application */
+               Msg.createEnvironment(args[0]);
+               Msg.deployApplication(args[1]);
+               
+               /*  execute the simulation. */
+           Msg.run();
+    }
+}
diff --git a/examples/priority/Test.java b/examples/priority/Test.java
new file mode 100644 (file)
index 0000000..365e8df
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 priority;
+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 Test extends Process {
+       public Test(Host host, String name, String[]args) {
+               super(host,name,args);
+       }
+       public void main(String[] args) throws MsgException {   
+               double computationAmount = 1.0;
+               double priority = 1.0;
+               
+               computationAmount = Double.valueOf(args[0]);
+               priority = Double.valueOf(args[1]);
+               
+               Msg.info("Hello! Running a task of size " + computationAmount + " with priority " + priority);
+               
+               Task task = new Task("Task", computationAmount, 0);
+               task.setPriority(priority);
+               
+               task.execute();
+               
+               Msg.info("Goodbye now!");
+       }
+}
diff --git a/examples/priority/priority.tesh b/examples/priority/priority.tesh
new file mode 100644 (file)
index 0000000..9501626
--- /dev/null
@@ -0,0 +1,15 @@
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar priority/Priority ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/priority/priorityDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Ready to run MSG_MAIN
+> [  0.000000] (1:priority.Test@Fafard) Hello! Running a task of size 7.6296E7 with priority 1.0
+> [  0.000000] (2:priority.Test@Fafard) Hello! Running a task of size 7.6296E7 with priority 2.0
+> [  0.833332] (2:priority.Test@Fafard) Goodbye now!
+> [  1.111109] (0:@) Done running MSG_MAIN
+> [  1.111109] (0:@) MSG_main finished
+> [  1.111109] (0:@) Clean java world
+> [  1.111109] (0:@) Clean native world
+> [  1.111109] (1:priority.Test@Fafard) Goodbye now!
+
diff --git a/examples/priority/priorityDeployment.xml b/examples/priority/priorityDeployment.xml
new file mode 100644 (file)
index 0000000..78c4958
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Fafard" function="priority.Test">
+       <argument value="76296000"/>
+       <argument value="1.0"/>
+  </process>
+  <process host="Fafard" function="priority.Test">
+       <argument value="76296000"/>
+       <argument value="2.0"/>
+  </process>
+</platform>
diff --git a/examples/suspend/DreamMaster.java b/examples/suspend/DreamMaster.java
new file mode 100644 (file)
index 0000000..f3bb90d
--- /dev/null
@@ -0,0 +1,21 @@
+package suspend;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+public class DreamMaster extends Process {
+       public DreamMaster(Host host, String name, String[]args) {
+               super(host,name,args);
+       } 
+       public void main(String[] args) throws MsgException {
+               Msg.info("Let's create a lazy guy.");
+               Process lazyGuy = new LazyGuy(getHost(),"Lazy",null);
+               lazyGuy.start();
+               Msg.info("Let's wait a little bit...");
+               waitFor(10);
+               Msg.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
+               lazyGuy.resume();
+               Msg.info("OK, goodbye now.");
+       }
+}
\ No newline at end of file
diff --git a/examples/suspend/LazyGuy.java b/examples/suspend/LazyGuy.java
new file mode 100644 (file)
index 0000000..0904636
--- /dev/null
@@ -0,0 +1,17 @@
+package suspend;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+public class LazyGuy extends Process {
+       public LazyGuy(Host host, String name, String[]args) {
+               super(host,name,args);
+       } 
+       public void main(String[] args) throws MsgException {
+               Msg.info("Nobody's watching me ? Let's go to sleep.");
+               suspend();
+               Msg.info("Uuuh ? Did somebody call me ?");
+               Msg.info("Mmmh, goodbye now.");
+       }
+}
\ No newline at end of file
diff --git a/examples/suspend/Suspend.java b/examples/suspend/Suspend.java
new file mode 100644 (file)
index 0000000..b628c30
--- /dev/null
@@ -0,0 +1,21 @@
+package suspend;
+
+import org.simgrid.msg.Msg;
+
+public class Suspend {
+       public static void main(String[] args) {
+               /* initialize the MSG simulation. Must be done before anything else (even logging). */
+               Msg.init(args);
+       if(args.length < 2) {
+               Msg.info("Usage   : Suspend platform_file deployment_file");
+               Msg.info("example : Suspend platform.xml 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/suspend/suspend.tesh b/examples/suspend/suspend.tesh
new file mode 100644 (file)
index 0000000..323fb6a
--- /dev/null
@@ -0,0 +1,18 @@
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar suspend/Suspend ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/suspend/suspendDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Ready to run MSG_MAIN
+> [  0.000000] (1:suspend.DreamMaster@Jacquelin) Let's create a lazy guy.
+> [  0.000000] (1:suspend.DreamMaster@Jacquelin) Let's wait a little bit...
+> [  0.000000] (2:Lazy@Jacquelin) Nobody's watching me ? Let's go to sleep.
+> [ 10.000000] (0:@) Done running MSG_MAIN
+> [ 10.000000] (0:@) MSG_main finished
+> [ 10.000000] (0:@) Clean java world
+> [ 10.000000] (0:@) Clean native world
+> [ 10.000000] (1:suspend.DreamMaster@Jacquelin) Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!
+> [ 10.000000] (1:suspend.DreamMaster@Jacquelin) OK, goodbye now.
+> [ 10.000000] (2:Lazy@Jacquelin) Uuuh ? Did somebody call me ?
+> [ 10.000000] (2:Lazy@Jacquelin) Mmmh, goodbye now.
+
diff --git a/examples/suspend/suspendDeployment.xml b/examples/suspend/suspendDeployment.xml
new file mode 100644 (file)
index 0000000..af3d363
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Jacquelin" function="suspend.DreamMaster"/>
+</platform>
diff --git a/org/simgrid/msg/File.java b/org/simgrid/msg/File.java
new file mode 100644 (file)
index 0000000..0f85eb4
--- /dev/null
@@ -0,0 +1,66 @@
+package org.simgrid.msg;
+/**
+* Copyright 2012 The SimGrid team. All right 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.
+*
+*/
+
+public class File {
+       protected String storage;
+       /**
+        * Represents the bind between the java comm and the
+        * native C comm. You must never access it, since it is 
+        * automatically set.
+        */
+       public long bind = 0;
+       /**
+        * Constructor, opens the file.
+        * @param storage is the name where you can find the stream 
+        * @param path is the file location on the storage 
+        * @param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
+        */
+       public File(String storage, String path, String mode) {
+               this.storage = storage;
+               open(storage, path, mode);
+       }
+       protected void finalize() {
+               close(storage);
+       }
+       /**
+        * Opens the file whose name is the string pointed to by path. 
+        * @param storage is the name where you can find the stream 
+        * @param path is the file location on the storage
+        * @param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
+        */
+       protected native void open(String storage, String path, String mode);
+       /**
+        * Read elements of a file. 
+        * @param storage is the name where you can find the stream
+        * @param size of each element
+        * @param nMemb is the number of elements of data to write 
+        */
+       public native long read(String storage, long size, long nMemb);
+       /**
+        * Write elements into a file. 
+        * @param storage is the name where you can find the stream 
+        * @param size of each element  
+        * @param nMemb is the number of elements of data to write 
+        */
+       public native long write(String storage, long size, long nMemb);
+       /**
+        * Close the file.      
+        * @param storage is the name where you can find the stream 
+        */
+       public native void close(String storage);
+       
+       /**
+        * Class initializer, to initialize various JNI stuff
+        */
+       public static native void nativeInit();
+       static {
+               nativeInit();
+       }       
+}
\ No newline at end of file
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 82e6c4f..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.
         *
@@ -288,6 +303,12 @@ public abstract class Process implements Runnable {
        public int getPPID()  {
                return ppid;
        }
+       /**
+        * Set the kill time of the process
+        * @param killTime the time when the process is killed
+        */
+       public native void setKillTime(double killTime);
+       
        /**
         * This static method returns the currently running process.
         *
@@ -302,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.
@@ -371,6 +392,7 @@ public abstract class Process implements Runnable {
                 catch(ProcessKilledError pk) {
                         
                 }      
+               exit();
        }
 
        /**
@@ -381,7 +403,7 @@ public abstract class Process implements Runnable {
      */
        public abstract void main(String[]args) throws MsgException;
 
-    
+       public native void exit();    
        /**
         * Class initializer, to initialize various JNI stuff
         */
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 4b9b734..5f4a8bf 100644 (file)
@@ -76,7 +76,7 @@ public class RngStream {
         */
        public native void resetNextSubstream();
        /**
-        * If a = true the stream g will start generating antithetic variates, i.e., 1  U instead of U , until
+        * If a = true the stream g will start generating antithetic variates, i.e., 1 - U instead of U , until
         *  this method is called again with a = false.
         */
        public native void setAntithetic(boolean a);
@@ -91,14 +91,14 @@ public class RngStream {
        /**
          * Advances the state of the stream by k values, without modifying the states of other streams (as
          * in RngStream_SetSeed), nor the values of Bg and Ig associated with this stream. If e > 0, then
-         * k = 2e + c; if e < 0, then k = −2−e + c; and if e = 0, then k = c. Note: c is allowed to take
-         *negative values. We discourage the use of this procedure.     
+         * k = 2e + c; if e < 0, then k = -2-e + c; and if e = 0, then k = c. Note: c is allowed to take
+         * negative values. We discourage the use of this procedure.    
          */
        public native void advanceState(int e, int g);
        
        /**
         * Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), after advancing the state by one step. The returned number has 32 bits of precision
-        * in the sense that it is always a multiple of 1/(232  208), unless RngStream_IncreasedPrecis
+        * in the sense that it is always a multiple of 1/(232 - 208), unless RngStream_IncreasedPrecis
         * has been called for this stream.
         */
        public native double randU01();
index aaf5b10..92d5d97 100644 (file)
@@ -12,6 +12,7 @@
 #include <locale.h>
 
 #include "smx_context_java.h"
+#include "smx_context_cojava.h"
 
 #include "jmsg_process.h"
 
@@ -87,7 +88,18 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
 
   (*env)->GetJavaVM(env, &__java_vm);
 
-  smx_factory_initializer_to_use = SIMIX_ctx_java_factory_init;
+  if ((*env)->FindClass(env, "java/dyn/Coroutine")) {
+       XBT_VERB("Using Coroutines");
+       smx_factory_initializer_to_use = SIMIX_ctx_cojava_factory_init;
+  }
+  else {
+       XBT_VERB("Using java threads");
+       smx_factory_initializer_to_use = SIMIX_ctx_java_factory_init;
+  }
+  jthrowable exc = (*env)->ExceptionOccurred(env);
+  if (exc) {
+    (*env)->ExceptionClear(env);
+  }
 
   setlocale(LC_NUMERIC,"C");
 
@@ -231,7 +243,6 @@ static int create_jprocess(int argc, char *argv[]) {
   /* sets the PID and the PPID of the process */
   (*env)->SetIntField(env, jprocess, jprocess_field_Process_pid,(jint) MSG_process_get_PID(process));
   (*env)->SetIntField(env, jprocess, jprocess_field_Process_ppid, (jint) MSG_process_get_PPID(process));
-
        jprocess_bind(jprocess, process, env);
 
        return 0;
diff --git a/src/jmsg_file.c b/src/jmsg_file.c
new file mode 100644 (file)
index 0000000..3695fb8
--- /dev/null
@@ -0,0 +1,76 @@
+/* Functions related to the java file API.                            */
+/* Copyright (c) 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. */
+#include "jmsg_file.h"
+#include "jxbt_utilities.h"
+void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
+  (*env)->SetLongField(env, jfile, jfile_field_bind, (jlong) (long) (stream));
+}
+
+msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
+       msg_file_t file = (msg_file_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
+       return file;
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass cls) {
+       jclass class_File = (*env)->FindClass(env, "org/simgrid/msg/File");
+       jfile_field_bind = jxbt_get_jfield(env , class_File, "bind", "J");
+       xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath, jobject jmode) {
+
+       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
+       const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
+       const char *mode = (*env)->GetStringUTFChars(env, jmode, 0);
+
+       msg_file_t file = MSG_file_open(storage, path, mode);
+
+       jfile_bind(env, jfile, file);
+
+       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+       (*env)->ReleaseStringUTFChars(env, jpath, path);
+       (*env)->ReleaseStringUTFChars(env, jmode, mode);
+}
+JNIEXPORT jlong JNICALL
+Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jobject jstorage, jlong jsize, jlong jnmemb) {
+       msg_file_t file = jfile_get_native(env, jfile);
+
+       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
+
+       size_t n = MSG_file_read(storage, NULL,(size_t)jsize, (size_t)jnmemb, file);
+
+       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+
+       return (jlong)n;
+}
+
+JNIEXPORT jlong JNICALL
+Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jobject jstorage, jlong jsize, jlong jnmemb) {
+       msg_file_t file = jfile_get_native(env, jfile);
+
+       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
+
+       size_t n = MSG_file_write(storage, NULL, (size_t)jsize, (size_t)jnmemb, file);
+
+       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+
+       return (jlong)n;
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile, jobject jstorage) {
+       msg_file_t file = jfile_get_native(env, jfile);
+
+       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
+
+       MSG_file_close(storage, file);
+       jfile_bind(env, jfile, NULL);
+
+       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+
+}
+
diff --git a/src/jmsg_file.h b/src/jmsg_file.h
new file mode 100644 (file)
index 0000000..4202ea2
--- /dev/null
@@ -0,0 +1,50 @@
+/* Functions related to the java file API.                            */
+/* Copyright (c) 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. */
+
+#ifndef MSG_JFILE_H
+#define MSG_JFILE_H
+#include <jni.h>
+#include "msg/msg.h"
+
+jfieldID jfile_field_bind;
+
+void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream);
+msg_file_t jfile_get_native(JNIEnv *env, jobject jfile);
+/**
+ * Class                       org_simgrid_msg_File
+ * Method                      nativeInit
+ * Signature   ()V
+ */
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_nativeInit(JNIEnv*, jclass);
+/**
+ * Class                       org_simgrid_msg_File
+ * Method                      open
+ * Signature   (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_open(JNIEnv*, jobject, jobject, jobject, jobject);
+/**
+ * Class                       org_simgrid_msg_File
+ * Method                      read
+ */
+JNIEXPORT jlong JNICALL
+Java_org_simgrid_msg_File_read(JNIEnv*, jobject, jobject, jlong, jlong);
+/**
+ * Class                       org_simgrid_msg_File
+ * Method                      write
+ */
+JNIEXPORT jlong JNICALL
+Java_org_simgrid_msg_File_write(JNIEnv*, jobject, jobject, jlong, jlong);
+/**
+ * Class                       org_simgrid_msg_File
+ * Method                      close
+ */
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_File_close(JNIEnv*, jobject, jobject);
+
+#endif
index c01a132..9fae1d7 100644 (file)
@@ -56,7 +56,6 @@ JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Host_nativeInit(JNIEnv *env, jclass cls) {
        jclass class_Host = (*env)->FindClass(env, "org/simgrid/msg/Host");
        jhost_method_Host_constructor = (*env)->GetMethodID(env, class_Host, "<init>", "()V");
-       //FIXME: Don't use jxbt_get_sfield directly, it is slower.
        jhost_field_Host_bind = jxbt_get_jfield(env,class_Host, "bind", "J");
        jhost_field_Host_name = jxbt_get_jfield(env, class_Host, "name", "Ljava/lang/String;");
        if (!class_Host || !jhost_field_Host_name || !jhost_method_Host_constructor || !jhost_field_Host_bind) {
index 6b2284d..dc3d262 100644 (file)
 #include "jmsg_host.h"
 #include "jxbt_utilities.h"
 #include "smx_context_java.h"
+#include "smx_context_cojava.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject jprocess) {
+       if (smx_factory_initializer_to_use == SIMIX_ctx_cojava_factory_init) {
+                m_process_t process = jprocess_to_native_process(jprocess, env);
+                smx_context_t context = MSG_process_get_smx_ctx(process);
+                smx_ctx_cojava_stop(context);
+        }
+}
+
 jobject native_to_java_process(m_process_t process)
 {
   return ((smx_ctx_java_t)MSG_process_get_smx_ctx(process))->jprocess;
@@ -206,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);
@@ -224,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);
@@ -325,3 +335,8 @@ Java_org_simgrid_msg_Process_migrate(JNIEnv * env,
   /* change the host java side */
   (*env)->SetObjectField(env, jprocess, jprocess_field_Process_host, jhost);
 }
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdouble jkilltime) {
+       m_process_t process = jprocess_to_native_process(jprocess, env);
+       MSG_process_set_kill_time(process, (double)jkilltime);
+}
index a97c0dd..7d5bead 100644 (file)
@@ -22,6 +22,9 @@ jfieldID jprocess_field_Process_name;
 jfieldID jprocess_field_Process_pid;
 jfieldID jprocess_field_Process_ppid;
 
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
+
 
 jobject native_to_java_process(m_process_t process);
 
@@ -147,7 +150,7 @@ Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
 /*
  * Class               org_simgrid_msg_Process
  * Method              create
- * Signature   (Lsimgrid/msg/Host;)V
+ * Signature   (Lorg/simgrid/msg/Host;)V
  */
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_create(JNIEnv * env,
@@ -165,7 +168,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
 /*
  * Class               org_simgrid_msg_Process
  * Method              fromPID
- * Signature   (I)Lsimgrid/msg/Process;
+ * Signature   (I)Lorg/simgrid/msg/Process;
  */
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
     (JNIEnv *, jclass, jint);
@@ -173,29 +176,29 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
 /*
  * Class               org_simgrid_msg_Process
  * Method              currentProcess
- * Signature   ()Lsimgrid/msg/Process;
+ * Signature   ()Lorg/simgrid/msg/Process;
  */
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
     (JNIEnv *, jclass);
 /*
  * Class               org_simgrid_msg_Process
- * Method              pause
- * Signature   (Lsimgrid/msg/Process;)V
+ * 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
- * Signature   (Lsimgrid/msg/Process;)V
+ * 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
  * Method              isSuspended
- * Signature   (Lsimgrid/msg/Process;)Z
+ * Signature   (Lorg/simgrid/msg/Process;)Z
  */
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
     (JNIEnv *, jobject);
@@ -217,7 +220,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
 /*
  * Class               org_simgrid_msg_Process
  * Method              kill
- * Signature   (Lsimgrid/msg/Process;)V
+ * Signature   (Lorg/simgrid/msg/Process;)V
  */
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
     (JNIEnv *, jobject);
@@ -225,8 +228,16 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
 /*
  * Class               org_simgrid_msg_Process
  * Method              migrate
- * Signature   (Lsimgrid/msg/Host;)V
+ * Signature   (Lorg/simgrid/msg/Host;)V
  */
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
     (JNIEnv *, jobject, jobject);
+/*
+ * Class               org_simgrid_msg_Process
+ * Method              setKillTime
+ * Signature   (D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
+    (JNIEnv *, jobject, jdouble);
+
 #endif                          /* !MSG_JPROCESS_H */
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 9eb973c..b758464 100644 (file)
@@ -56,7 +56,7 @@ Java_org_simgrid_msg_Task_nativeInit(JNIEnv *env, jclass cls) {
        if (!jtask_field_Task_bind || !jtask_class_Task || !jtask_field_Comm_bind || !jtask_field_Comm_taskBind ||
                  !jtask_field_Comm_receiving || !jtask_method_Comm_constructor) {
                        jxbt_throw_native(env,bprintf("Can't find some fields in Java class."));
-                 }
+       }
 }
 
 JNIEXPORT void JNICALL
@@ -410,7 +410,9 @@ Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls,
                                        jobject jhost)
 {
   MSG_error_t rv;
-  m_task_t task = NULL;
+  m_task_t *task = xbt_new(m_task_t,1);
+  *task = NULL;
+
   m_host_t host = NULL;
   jobject jtask_global, jtask_local;
   const char *alias;
@@ -426,7 +428,7 @@ Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls,
 
   alias = (*env)->GetStringUTFChars(env, jalias, 0);
   TRY {
-       rv = MSG_task_receive_ext(&task, alias, (double) jtimeout, host);
+       rv = MSG_task_receive_ext(task, alias, (double) jtimeout, host);
   }
   CATCH_ANONYMOUS {
        return NULL;
@@ -435,15 +437,17 @@ Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls,
        jmsg_throw_status(env,rv);
        return NULL;
   }
-  jtask_global = MSG_task_get_data(task);
+  jtask_global = MSG_task_get_data(*task);
 
   /* Convert the global ref into a local ref so that the JVM can free the stuff */
   jtask_local = (*env)->NewLocalRef(env, jtask_global);
   (*env)->DeleteGlobalRef(env, jtask_global);
-  MSG_task_set_data(task, NULL);
+  MSG_task_set_data(*task, NULL);
 
   (*env)->ReleaseStringUTFChars(env, jalias, alias);
 
+  xbt_free(task);
+
   jxbt_check_res("MSG_task_receive_ext()", rv,
                  MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
                  bprintf("while receiving from mailbox %s", alias));
diff --git a/src/smx_context_cojava.c b/src/smx_context_cojava.c
new file mode 100644 (file)
index 0000000..2905ece
--- /dev/null
@@ -0,0 +1,268 @@
+/* context_cojava - implementation of context switching for java coroutines */
+
+/* Copyright 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. */
+
+
+#include <xbt/function_types.h>
+#include <simgrid/simix.h>
+#include <xbt/ex.h>
+#include "smx_context_cojava.h"
+#include "jxbt_utilities.h"
+#include "xbt/dynar.h"
+
+
+//Coroutine methodID/class cache.
+jclass coclass;
+jmethodID coroutine_init;
+jmethodID coroutine_yield;
+jmethodID coroutine_yieldTo;
+jmethodID coroutine_stop;
+//Maestro java coroutine
+jobject cojava_maestro_coroutine;
+
+JNIEnv *global_env;
+
+static smx_context_t my_current_context = NULL;
+static smx_context_t maestro_context = NULL;
+
+
+xbt_dynar_t cojava_processes;
+static unsigned long int cojava_process_index = 0;
+
+static JavaVM *get_current_vm(void);
+static JavaVM *get_current_vm(void)
+{
+       JavaVM *jvm;
+       JNI_GetCreatedJavaVMs(&jvm,1,NULL);
+  return jvm;
+}
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
+
+
+static smx_context_t
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
+                                    char **argv,
+                                    void_pfn_smxprocess_t cleanup_func,
+                                    void *data);
+
+static void smx_ctx_cojava_free(smx_context_t context);
+static void smx_ctx_cojava_start(smx_context_t context);
+static void smx_ctx_cojava_suspend(smx_context_t context);
+static void smx_ctx_cojava_resume(smx_context_t new_context);
+static void smx_ctx_cojava_runall(void);
+static void* smx_ctx_cojava_run(void *data);
+static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context);
+void SIMIX_ctx_cojava_factory_init(smx_context_factory_t * factory)
+{
+  /* instantiate the context factory */
+  smx_ctx_base_factory_init(factory);
+
+  (*factory)->create_context = smx_ctx_cojava_factory_create_context;
+  /* Leave default behavior of (*factory)->finalize */
+  (*factory)->free = smx_ctx_cojava_free;
+  (*factory)->stop = smx_ctx_cojava_stop;
+  (*factory)->suspend = smx_ctx_cojava_suspend;
+  (*factory)->runall = smx_ctx_cojava_runall;
+  (*factory)->name = "ctx_cojava_factory";
+  //(*factory)->finalize = smx_ctx_base_factory_finalize;
+  (*factory)->self = smx_ctx_cojava_self;
+  (*factory)->get_data = smx_ctx_base_get_data;
+
+  global_env = get_current_thread_env();
+
+  coclass = (*global_env)->FindClass(global_env, "java/dyn/Coroutine");
+  xbt_assert((coclass != NULL), "Can't find java.dyn.Coroutine class.");
+  //Cache the method id we are going to use
+  coroutine_init = (*global_env)->GetMethodID(global_env, coclass, "<init>", "(Ljava/lang/Runnable;)V");
+  xbt_assert((coroutine_init != NULL), "Can't find <init>");
+  coroutine_stop = (*global_env)->GetMethodID(global_env, coclass, "stop", "()V");
+  xbt_assert((coroutine_stop != NULL), "Method not found...");
+  coroutine_yield = (*global_env)->GetStaticMethodID(global_env, coclass, "yield", "()V");
+       xbt_assert((coroutine_yield != NULL), "Method yield not found.");
+       coroutine_yieldTo = (*global_env)->GetStaticMethodID(global_env, coclass, "yieldTo", "(Ljava/dyn/Coroutine;)V");
+       xbt_assert((coroutine_yieldTo != NULL), "Method yieldTo not found.");
+
+       jclass class_thread = (*global_env)->FindClass(global_env, "java/lang/Thread");
+       xbt_assert((class_thread != NULL), "Can't find java.lang.Thread class");
+       jclass class_coroutine_support = (*global_env)->FindClass(global_env, "java/dyn/CoroutineSupport");
+       xbt_assert((class_coroutine_support != NULL), "Can't find java.dyn.CoroutineSupport class");
+       jmethodID thread_get_current = (*global_env)->GetStaticMethodID(global_env, class_thread, "currentThread", "()Ljava/lang/Thread;");
+       xbt_assert((thread_get_current != NULL), "Can't find Thread.currentThread() method.");
+
+       /**
+        * Retrieve maetro coroutine object
+        */
+       jobject jthread;
+       jthread = (*global_env)->CallStaticObjectMethod(global_env, class_thread, thread_get_current);
+       xbt_assert((jthread != NULL), "Can't find current thread.");
+
+       jmethodID thread_get_coroutine_support = (*global_env)->GetMethodID(global_env, class_thread, "getCoroutineSupport", "()Ljava/dyn/CoroutineSupport;");
+       xbt_assert((thread_get_coroutine_support != NULL), "Can't find Thread.getCoroutineSupport method");
+
+       jobject jcoroutine_support;
+       jcoroutine_support = (*global_env)->CallObjectMethod(global_env, jthread, thread_get_coroutine_support);
+       xbt_assert((jcoroutine_support != NULL), "Can't find coroutine support object");
+       //FIXME ? Be careful, might change in the implementation (we are relying on private fields, so...).
+       jfieldID coroutine_support_thread_coroutine = (*global_env)->GetFieldID(global_env, class_coroutine_support, "threadCoroutine", "Ljava/dyn/Coroutine;");
+       xbt_assert((coroutine_support_thread_coroutine != NULL), "Can't find threadCoroutine field");
+       cojava_maestro_coroutine = (jobject)(*global_env)->GetObjectField(global_env, jcoroutine_support, coroutine_support_thread_coroutine);
+       xbt_assert((cojava_maestro_coroutine != NULL), "Can't find the thread coroutine.");
+       cojava_maestro_coroutine = (*global_env)->NewGlobalRef(global_env, cojava_maestro_coroutine);
+       xbt_assert((cojava_maestro_coroutine != NULL), "Can't get a global reference to the thread coroutine.");
+}
+smx_context_t smx_ctx_cojava_self(void)
+{
+       return my_current_context;
+}
+
+static smx_context_t
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
+                                    char **argv,
+                                    void_pfn_smxprocess_t cleanup_func,
+                                    void* data)
+{
+       smx_ctx_cojava_t context = xbt_new0(s_smx_ctx_cojava_t, 1);
+  /* If the user provided a function for the process then use it
+     otherwise is the context for maestro */
+  if (code) {
+               if (argc == 0) {
+                       context->jprocess = (jobject) code;
+               }
+               else {
+                       context->jprocess = NULL;
+               }
+               context->super.cleanup_func = cleanup_func;
+
+               context->super.argc = argc;
+               context->super.argv = argv;
+               context->super.code = code;
+
+               smx_ctx_cojava_run(context);
+  }
+  else {
+       context->jcoroutine = NULL;
+       my_current_context = (smx_context_t)context;
+       maestro_context = (smx_context_t)context;
+  }
+  context->bound = 0;
+  context->super.data = data;
+  return (smx_context_t) context;
+}
+
+static void* smx_ctx_cojava_run(void *data) {
+       smx_ctx_cojava_t context = (smx_ctx_cojava_t)data;
+       my_current_context = (smx_context_t)context;
+       //Create the "Process" object if needed.
+       if (context->super.argc <= 0) {
+               smx_ctx_cojava_create_coroutine(context);
+       }
+       my_current_context = maestro_context;
+  return NULL;
+}
+static void smx_ctx_cojava_free(smx_context_t context)
+{
+       if (context) {
+               smx_ctx_cojava_t ctx_java = (smx_ctx_cojava_t) context;
+               if (ctx_java->jcoroutine) { /* We are not in maestro context */
+                       JNIEnv *env = get_current_thread_env();
+                       (*env)->DeleteGlobalRef(env, ctx_java->jcoroutine);
+                       (*env)->DeleteGlobalRef(env, ctx_java->jprocess);
+               }
+  }
+  smx_ctx_base_free(context);
+}
+
+
+void smx_ctx_cojava_stop(smx_context_t context)
+{
+       /*
+        * The java stack needs to be empty, otherwise weird stuff
+        * will happen
+        */
+       if (context->iwannadie) {
+       context->iwannadie = 0;
+       JNIEnv *env = get_current_thread_env();
+       jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process killed :)"));
+       THROWF(cancel_error, 0, "process cancelled");
+  }
+       else {
+               smx_ctx_base_stop(context);
+               smx_ctx_cojava_suspend(context);
+       }
+}
+
+static void smx_ctx_cojava_suspend(smx_context_t context)
+{
+       smx_context_t previous_context = context;
+       unsigned long int i = cojava_process_index++;
+       jobject next_coroutine;
+
+       if (i < xbt_dynar_length(cojava_processes)) {
+               smx_context_t next_context = SIMIX_process_get_context(xbt_dynar_get_as(
+                               cojava_processes,i, smx_process_t));
+               my_current_context = next_context;
+               XBT_DEBUG("Switching to %p",my_current_context);
+               smx_ctx_cojava_t java_context = (smx_ctx_cojava_t)(next_context);
+
+               if (!java_context->jprocess) {
+                       (*(java_context->super.code))(java_context->super.argc, java_context->super.argv);
+                       smx_ctx_cojava_create_coroutine(java_context);
+               }
+               else if (!java_context->bound) {
+                       java_context->bound = 1;
+                       smx_process_t process = SIMIX_process_self();
+                       (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+               }
+
+               next_coroutine = java_context->jcoroutine;
+       }
+       else {
+               //Give maestro the control back.
+               next_coroutine = cojava_maestro_coroutine;
+               my_current_context = maestro_context;
+       }
+  (*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, next_coroutine);
+  my_current_context = previous_context;
+}
+
+static void smx_ctx_cojava_resume(smx_context_t new_context) {
+       my_current_context = new_context;
+       smx_ctx_cojava_t java_context = (smx_ctx_cojava_t)(new_context);
+
+       if (!java_context->jprocess) {
+               (*(java_context->super.code))(java_context->super.argc, java_context->super.argv);
+               smx_ctx_cojava_create_coroutine(java_context);
+               java_context->bound = 1;
+       }
+       else if (!java_context->bound) {
+               java_context->bound = 1;
+               smx_process_t process = SIMIX_process_self();
+               (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+       }
+  (*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, java_context->jcoroutine);
+}
+
+static void smx_ctx_cojava_runall(void)
+{
+  cojava_processes = SIMIX_process_get_runnable();
+       smx_process_t process;
+       process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t);
+       cojava_process_index = 1;
+       /* Execute the first process */
+       smx_ctx_cojava_resume(SIMIX_process_get_context(process));
+}
+
+static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context) {
+       JNIEnv *env = get_current_thread_env();
+       jclass coclass = (*env)->FindClass(env, "java/dyn/Coroutine");
+  xbt_assert((coclass != NULL), "Can't find coroutine class ! :(");
+  jobject jcoroutine = (*env)->NewObject(env, coclass, coroutine_init, context->jprocess);
+  xbt_assert((jcoroutine != NULL), "Can't create coroutine object.");
+  jcoroutine = (*env)->NewGlobalRef(env, jcoroutine);
+  context->jcoroutine = jcoroutine;
+}
diff --git a/src/smx_context_cojava.h b/src/smx_context_cojava.h
new file mode 100644 (file)
index 0000000..1f7a8de
--- /dev/null
@@ -0,0 +1,32 @@
+/* Copyright (c) 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. */
+
+#ifndef _XBT_CONTEXT_COJAVA_H
+#define _XBT_CONTEXT_COJAVA_H
+
+#include <xbt/misc.h>
+#include <simgrid/simix.h>
+#include <xbt/xbt_os_thread.h>
+
+#include "jmsg.h"
+#include "jmsg_process.h"
+
+SG_BEGIN_DECL()
+
+typedef struct s_smx_ctx_cojava {
+  s_smx_ctx_base_t super;       /* Fields of super implementation */
+  jobject jprocess;             /* the java process instance binded with the msg process structure */
+  JNIEnv *jenv;                 /* jni interface pointer associated to this thread */
+  jobject jcoroutine;                                          /* java coroutine object */
+  int bound:1;
+} s_smx_ctx_cojava_t, *smx_ctx_cojava_t;
+
+void SIMIX_ctx_cojava_factory_init(smx_context_factory_t *factory);
+void smx_ctx_cojava_stop(smx_context_t context);
+smx_context_t smx_ctx_cojava_self(void);
+SG_END_DECL()
+
+#endif                          /* !_XBT_CONTEXT_JAVA_H */
index b327df5..91a3b93 100644 (file)
@@ -1,6 +1,6 @@
 /* context_java - implementation of context switching for java threads */
 
-/* Copyright (c) 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2009, 2010, 2012. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -99,6 +99,10 @@ static void* smx_ctx_java_thread_run(void *data) {
        if (context->super.argc > 0) {
                (*(context->super.code))(context->super.argc, context->super.argv);
        }
+       else {
+               smx_process_t process = SIMIX_process_self();
+               (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind, (jlong)process);
+       }
        xbt_assert((context->jprocess != NULL), "Process not created...");
   //wait for the process to be able to begin
   //TODO: Cache it
@@ -134,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 :)"));
index 4142bf1..084c5d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2009, 2010, 2012. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it