Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid-java
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 19 Oct 2011 12:06:21 +0000 (14:06 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 19 Oct 2011 12:06:21 +0000 (14:06 +0200)
examples/master_slave_bypass/Master.java
examples/master_slave_bypass/MsBypass.java
org/simgrid/msg/Msg.java
src/jmsg.c
src/jmsg.h

index 393d896da7621271c0371ed698291323b49e8ec7..1b06544eb6b566786c2638c4a208d6b77f653d3c 100644 (file)
@@ -26,7 +26,7 @@ public class Master extends Process {
        //Create a slave on host "alice"
        try {
                        Msg.info("Create process on host 'alice'");
-               Slave process2 = new Slave("alice","process2");
+               new Slave("alice","process2");
            }
        catch (MsgException e){
                        System.out.println("Process2!");
index cc95c83343e223c3f8645936e7443bf4af42fa6e..1ddbc1c806e2d3f3d29cfa0829ffe9fbe8c06a32 100644 (file)
@@ -24,9 +24,9 @@ public class MsBypass {
     Msg.init(args);
     Msg.createEnvironment(args[0]);
 
-    /* bypass deploymemt */
+    /* bypass deployment */
     try {
-    Master process1 = new Master("bob","process1");
+       new Master("bob","process1");
     }
     catch (MsgException e){
        System.out.println("Create processes failed!");
index 64c0713ad3ea0c8cc99ee21386097f8f5f78c41c..883dbf52953aeec4104244c7c8d646d4fe01d0ed 100644 (file)
@@ -76,14 +76,29 @@ public final class Msg {
        public final static native void init(String[]args);
 
        /**
-        * Run the MSG simulation, and cleanup everything afterward.
+        * Run the MSG simulation.
         *
-        * If you want to chain simulations in the same process, you
-        * should call again createEnvironment and deployApplication afterward.
+        * The simulation is not cleaned afterward (see  
+        * {@link #clean()} if you really insist on cleaning the C side), so you can freely 
+        * retrieve the informations that you want from the simulation. In particular, retrieving the status 
+        * of a process or the current date is perfectly ok. 
         *
-        * @see                    MSG_run, MSG_clean
+        * @see                    MSG_run
         */
        public final static native void run() ;
+       
+       /**
+        * Cleanup the MSG simulation.
+        * 
+        * This function is only useful if you want to chain the simulations within 
+        * the same environment. But actually, it's not sure at all that cleaning the 
+        * JVM is faster than restarting a new one, so it's probable that using this 
+        * function is not a brilliant idea. Do so at own risk.
+        *      
+        * @see                    MSG_clean
+        */
+       public final static native void clean();
+       
 
        /**
         * The native implemented method to create the environment of the simulation.
index ae5dd0a6f249651dc7535485159d584614f78364..b25f487267691234cdd70b04ff129169f2b44cbf 100644 (file)
@@ -725,13 +725,11 @@ Java_org_simgrid_msg_MsgNative_taskDestroy(JNIEnv * env, jclass cls,
 
   /* get the native task */
   m_task_t task = jtask_to_native_task(jtask_arg, env);
-//  jobject jtask;
 
   if (!task) {
     jxbt_throw_notbound(env, "task", task);
     return;
   }
-//  jtask = (jobject) MSG_task_get_data(task);
 
   MSG_error_t rv = MSG_task_destroy(task);
 
@@ -797,7 +795,6 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
     jval = (jstring) (*env)->GetObjectArrayElement(env, jargs, index);
     tmp = (*env)->GetStringUTFChars(env, jval, 0);
     argv[index + 1] = strdup(tmp);
-    //argv[index] = strdup(tmp);
     (*env)->ReleaseStringUTFChars(env, jval, tmp);
   }
 
@@ -815,7 +812,7 @@ JNIEXPORT void JNICALL
     JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
 {
   MSG_error_t rv;
-  int index;                    //xbt_fifo_item_t item = NULL;
+  int index;
   m_host_t *hosts;
   jobject jhost;
 
@@ -840,13 +837,17 @@ JNIEXPORT void JNICALL
   }
 
   XBT_INFO("Clean native world");
-  /* cleanup native stuff */
-  rv = MSG_OK != MSG_clean();
+}
+JNIEXPORT void JNICALL
+    JNICALL Java_org_simgrid_msg_Msg_clean(JNIEnv * env, jclass cls)
+{
+  /* cleanup native stuff. Calling it is ... useless since leaking memory at the end of the simulation is a non-issue */
+  MSG_error_t rv = MSG_OK != MSG_clean();
   jxbt_check_res("MSG_clean()", rv, MSG_OK,
                  bprintf
                  ("unexpected error : MSG_clean() failed .. please report this bug "));
 }
-
+   
 JNIEXPORT jint JNICALL
 Java_org_simgrid_msg_MsgNative_processKillAll(JNIEnv * env, jclass cls,
                                           jint jresetPID)
index 8bf5a941f3c6343a3c7576fe85aa9333c647cf05..bfa02c14e23b7a77d95d953a82502da78f07391d 100644 (file)
@@ -293,6 +293,8 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv *, jclass);
 
 JNIEXPORT void JNICALL
     JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls);
+JNIEXPORT void JNICALL
+    JNICALL Java_org_simgrid_msg_Msg_clean(JNIEnv * env, jclass cls);
 
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs);