From: Jonathan Rouzaud-Cornabas Date: Thu, 17 Jan 2013 10:29:37 +0000 (+0100) Subject: Merge branch 'vmtrace' X-Git-Tag: v3_9_90~569^2~19^2~8 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/410c20fdb9b68068548b9f4686eae70898a2b0ba?hp=b981d712b790bf9db2525e0b36e728865e8febc1 Merge branch 'vmtrace' --- diff --git a/CMakeLists.txt b/CMakeLists.txt index dd569335c3..e1cf067d75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib") set(soversion 1) set(SIMGRID_JAVA_VERSION_MAJOR "3") -set(SIMGRID_JAVA_VERSION_MINOR "8") +set(SIMGRID_JAVA_VERSION_MINOR "9") set(SIMGRID_JAVA_VERSION_PATCH "0") set(DIST_NAME ${PROJECT_NAME}-${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR}.${SIMGRID_JAVA_VERSION_PATCH}) @@ -156,6 +156,7 @@ set(JAVA_EXAMPLES ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorAnswerTask.java ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorTask.java ${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorAnswerTask.java + ${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorTask.java ${CMAKE_HOME_DIRECTORY}/examples/chord/NotifyTask.java ${CMAKE_HOME_DIRECTORY}/examples/cloud/Cloud.java ${CMAKE_HOME_DIRECTORY}/examples/cloud/FinalizeTask.java @@ -221,6 +222,8 @@ set(JAVA_TRACING_EXAMPLES set(CMAKE_SRC ${CMAKE_HOME_DIRECTORY}/ChangeLog + ${CMAKE_HOME_DIRECTORY}/MANIFEST.MF + ${CMAKE_HOME_DIRECTORY}/COPYING ${CMAKE_HOME_DIRECTORY}/CMakeLists.txt ${CMAKE_HOME_DIRECTORY}/doxygen_postprocesser.pl ${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake @@ -370,6 +373,17 @@ if(HAVE_TRACING) ) endif(HAVE_TRACING) +IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86") + IF(${ARCH_32_BITS}) + set(JSG_BUNDLE NATIVE/${CMAKE_SYSTEM_NAME}/x86/) + ELSE() + set(JSG_BUNDLE NATIVE/${CMAKE_SYSTEM_NAME}/amd64/) + ENDIF() +ELSE() + error("Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}") +ENDIF() +message("Native libraries bundeled into: ${JSG_BUNDLE}") + # java_classes add_custom_command( OUTPUT ${JAVA_SRC_CLASS} @@ -377,6 +391,13 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/" COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/ -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_SRC} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE} + COMMAND ${CMAKE_COMMAND} -E copy ${SIMGRID_LIB_PATH}/libsimgrid.so ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE} + COMMAND strip --strip-debug ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE}/libsimgrid.so + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/lib/libSG_java.so ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE} + COMMAND strip --strip-debug ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE}/libSG_java.so + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/ChangeLog ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/COPYING ${CMAKE_HOME_DIRECTORY}/classes/${JSG_BUNDLE} COMMENT "Compiling java sources of core library..." ) @@ -386,7 +407,7 @@ add_custom_target(java_classes ALL # simgrid_jar add_custom_target(simgrid_jar ALL - COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar . + COMMAND ${JAVA_ARCHIVE} -cmvf ${CMAKE_HOME_DIRECTORY}/MANIFEST.MF ${CMAKE_HOME_DIRECTORY}/simgrid.jar . COMMENT "Building simgrid.jar..." WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes ) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000000..a13f68bc22 --- /dev/null +++ b/COPYING @@ -0,0 +1,9 @@ +All of the Java bindings to the SimGrid software was written +internally by the team. This software is distributed under the GNU +lesser general public license version 2.1, which you can find in the +archive under the name LICENSE-LGPL-2.1. + +For any copyright year range specified as YYYY-ZZZZ in this package +note that the range specifies every single year in that closed interval. + +The SimGrid logo is distributed under the CC-BY-SA license. diff --git a/ChangeLog b/ChangeLog index 756275795e..2ef198922b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -SimGrid-java (3.8) unstable; urgency=low +SimGrid-java (3.8.1) unstable; urgency=low * New module: org.simgrid.trace.Trace (SimGrid trace bindings) Warning: all methods are visible, but only some of them are @@ -13,11 +13,15 @@ SimGrid-java (3.8) unstable; urgency=low * Add Process.getProperty, Host.getProperty, Host.getProperty: allows you to retrieve the properties of the processes/hosts * Deprecate Msg.clean(): you can just forget about it now. + * New function Process.getCount(), that only works when compiling + with the not yet released version 3.9 of the C library. * New context factory based on Coroutines. It mandates a modified JVM but then, the simulations run about five times faster, and there is no limit to the amount of processes (beside of the available memory). - + + -- 2012-12-04 Da SimGrid team + SimGrid-java (3.7.1) stable; urgency=low The "Java aint got to be bloated and slow" release diff --git a/FindJavaSG.cmake b/FindJavaSG.cmake index 92d254dfaf..47bddfdb33 100644 --- a/FindJavaSG.cmake +++ b/FindJavaSG.cmake @@ -1,6 +1,9 @@ +set(JAVA_INCLUDE_PATH "$ENV{JAVA_INCLUDE_PATH}") +set(JAVA_INCLUDE_PATH2 "$ENV{JAVA_INCLUDE_PATH}") + include(FindJava) include(FindJNI) - + message(STATUS "Looking for jni.h") if(JAVA_INCLUDE_PATH) message(STATUS "Looking for jni.h - found") diff --git a/MANIFEST.MF b/MANIFEST.MF new file mode 100644 index 0000000000..8d2c03944a --- /dev/null +++ b/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: Da SimGrid team +Main-Class: org.simgrid.msg.Msg +Class-Path: . + diff --git a/doc/install.doc b/doc/install.doc index 0d88aff5bb..0dc293c9d1 100644 --- a/doc/install.doc +++ b/doc/install.doc @@ -3,13 +3,13 @@ \section bindings_binding_java_install How to install Simgrid-java To use java with Simgrid you have to install some dependencies: - \li Simgrid (see install + \li Simgrid (see install Simgrid). You should set the SIMGRID_ROOT environment variable to the path where you installed SimGrid. - \li Java JDK packages, such as sun-java6-jdk (with libgcj10-dev or -another version of gcj) or openjdk6. For maximal performance and -scalability, use a coroutine-enabled JVM (see -\ref bindings_binding_java_coroutines). + \li Java JDK packages, such as openjdk7 or sun-java6-jdk (with + libgcj10-dev or another version of gcj). For maximal performance + and scalability, use a coroutine-enabled JVM (see + \ref bindings_binding_java_coroutines). Then Download and install package Simgrid-java: \verbatim @@ -25,7 +25,7 @@ Cmake output -- BUILDNAME : Simgrid-Java -- Looking for lib SimGrid -- Looking for lib SimGrid - found --- Simgrid version : 3.6 +-- Simgrid version : 3.8.1 -- Looking for gras.h -- Looking for gras.h - found -- Found Tesh: /home/user/Bureau/simgrid/git/bin/tesh @@ -43,6 +43,27 @@ Cmake output -- Build files have been written to: /home/user/workspace/simgrid-java/build \endverbatim +If cmake complains that jni could not be found, you need to +tell it where JNI header files are located. the following command +should tell you: + +\verbatim +$ locate jni.h +/usr/lib/jvm/java-6-openjdk-amd64/include/jni.h +/usr/lib/jvm/java-7-openjdk-amd64/include/jni.h +\endverbatim + +If you have several version of jni installed (as in the example +above), you need to check the version of java that is used by default +on your machine (using javac -version), and pick the right one. Then +set the JAVA_INCLUDE_PATH environment variable to the right path (note +that we remove the filename jni.h from that path), and relaunch cmake. + +\verbatim +$ export JAVA_INCLUDE_PATH=/usr/lib/jvm/java-6-openjdk-amd64/include/ +$ cmake . +\endverbatim + \section bindings_binding_java_use How to use Simgrid-java To execute the examples you need to add the path where you installed @@ -53,16 +74,15 @@ Be careful on Mac, this variable is called DYLD_LIBRARY_PATH and not LD_LIBRARY_PATH. \verbatim -$ export SIMGRID_ROOT="$HOME/Install/simgrid/" -$ export SIMGRID_JAVA_ROOT="$HOME/Install/simgrid-java" -$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SIMGRID_ROOT/lib:$SIMGRID_JAVA_ROOT/java +$ export SIMGRID_ROOT="$HOME/Install/simgrid/" # change it to the path where you installed the SimGrid library +$ export SIMGRID_JAVA_ROOT="$HOME/Install/simgrid-java" # change it to the path where you installed the java bindings of SimGrid +$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$SIMGRID_ROOT/lib:$SIMGRID_JAVA_ROOT/java $ cd examples $ java -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml \endverbatim - - - +If you want to make these settings permanent even after a reboot, you +need to add the export lines into your ~/.bashrc file, or equivalent. @@ -87,6 +107,10 @@ migrate stacks in SimGrid. You should be able to follow the README.txt that you'll get in the repository, but here is how we did it, just in case. The instructions are given for a debian or Ubuntu box, but I think you should manage to convert it to your system quite easily. +Finally, if you're really stuck, you can get the version compiled by +Jonathan Rouzaud-Cornabas from his web page. This version is known to +work with SimGrid for sure! +http://graal.ens-lyon.fr/~jrouzaud/files/corosimple-linux-amd64-20120914.tgz -# Install mercurial and some dependencies \verbatim @@ -179,9 +203,23 @@ you want to increase it to run more processes. $ $PATH_TO_COROUTINE_JVM/java -Dcoro.stacksPerThread=$STACKS_NUMBER -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml \endverbatim -If you feel limited in the amount of processes you can run, give a try -to this command: +If you reach the point where the creation of new simulated processes +fail with the message "Can't create coroutine object", you may need to +increase the relevant system limit with the following command. \verbatim sysctl -w vm.max_map_count = 131072 \endverbatim + +The full story is that each coroutine requires two memory maps, and +that Linux puts a limit on the total amount of memory maps that each +process can manage (by default, this limit is often at 65535). Since +the JVM needs a few dozen of such maps on its own (three maps per +dynamic library -- check /proc/the_pid/maps if you don't believe it), +this is enough to create over 30,000 simulated processes. But to go +futher, that limit must be modified. + +If you want to make this change permanent on your machine, edit your +/etc/sysctl.conf file. Otherwise, you have to redo it by calling +sysctl after each reboot. + */ diff --git a/examples/async/async.tesh b/examples/async/async.tesh index 8782d071cd..2efb017f36 100644 --- a/examples/async/async.tesh +++ b/examples/async/async.tesh @@ -3,7 +3,6 @@ ! output sort $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar async/AsyncTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/async/asyncDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (0:@) Ready to run MSG_MAIN > [ 0.000000] (10:async.Slave@Robert) Receiving on 'slave_8' > [ 0.000000] (11:async.Slave@Sirois) Receiving on 'slave_9' > [ 0.000000] (12:async.Slave@Monique) Receiving on 'slave_10' @@ -53,8 +52,5 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar async/AsyncTest ${sr > [ 25.000000] (1:async.Master@Jacquelin) Goodbye now! > [ 25.851463] (2:async.Forwarder@Jackson) I'm done. See you! > [ 26.357007] (3:async.Forwarder@Casavant) I'm done. See you! -> [ 29.000728] (0:@) Done running MSG_MAIN -> [ 29.000728] (0:@) MSG_main finished -> [ 29.000728] (0:@) Clean java world -> [ 29.000728] (0:@) Clean native world +> [ 29.000728] (0:@) MSG_main finished; Cleaning up the simulation... > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. diff --git a/examples/bittorrent/bittorrent.tesh b/examples/bittorrent/bittorrent.tesh index e45857abd0..1e170eb136 100644 --- a/examples/bittorrent/bittorrent.tesh +++ b/examples/bittorrent/bittorrent.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar bittorrent/Bittorrent ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/bittorrent/bittorrent.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [5000.832370] [jmsg/INFO] Done running MSG_MAIN -> [5000.832370] [jmsg/INFO] MSG_main finished -> [5000.832370] [jmsg/INFO] Clean java world -> [5000.832370] [jmsg/INFO] Clean native world +> [5000.832370] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Boivin:bittorrent.Peer:(2) 0.000000] [jmsg/INFO] Hi, I'm joining the network with id 2 > [Boivin:bittorrent.Peer:(2) 5000.048882] [jmsg/INFO] Here is my current status: 1111111111 > [Disney:bittorrent.Peer:(6) 0.000000] [jmsg/INFO] Hi, I'm joining the network with id 6 diff --git a/examples/chord/chord.tesh b/examples/chord/chord.tesh index 9e21e8a637..ba3f52e2cb 100644 --- a/examples/chord/chord.tesh +++ b/examples/chord/chord.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar chord/Chord ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/chord/chord.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [652.548539] [jmsg/INFO] Done running MSG_MAIN -> [652.548539] [jmsg/INFO] MSG_main finished -> [652.548539] [jmsg/INFO] Clean java world -> [652.548539] [jmsg/INFO] Clean native world +> [652.548539] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Boivin:chord.Node:(7) 0.000000] [jmsg/INFO] Joining the ring with id 8 knowing node 1 > [Gatien:chord.Node:(1) 0.000000] [jmsg/INFO] Joining the ring with id 48 knowing node 1 > [Geoff:chord.Node:(4) 0.000000] [jmsg/INFO] Joining the ring with id 32 knowing node 1 diff --git a/examples/cloud/cloud.tesh b/examples/cloud/cloud.tesh index 9b191bdd25..bdb2c12ca6 100644 --- a/examples/cloud/cloud.tesh +++ b/examples/cloud/cloud.tesh @@ -3,7 +3,6 @@ ! output sort $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar cloud/Cloud ${srcdir:=.}/examples/platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (0:@) Ready to run MSG_MAIN > [ 0.000000] (10:Slave 8@Jean_Yves) Receiving on slave_8 > [ 0.000000] (11:Slave 9@Fafard) Receiving on slave_9 > [ 0.000000] (1:Master@Jacquelin) Launched 10 VMs @@ -151,10 +150,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar cloud/Cloud ${srcdir > [1021.445768] (20:Slave 18@Provost) Received "Task_18". Processing it. > [1021.445768] (20:Slave 18@Provost) "Task_18" done > [1021.445768] (20:Slave 18@Provost) Receiving on slave_18 -> [1023.430577] (0:@) Done running MSG_MAIN -> [1023.430577] (0:@) MSG_main finished -> [1023.430577] (0:@) Clean java world -> [1023.430577] (0:@) Clean native world +> [1023.430577] (0:@) MSG_main finished; Cleaning up the simulation... > [1023.430577] (1:Master@Jacquelin) Let's shut down the simulation and kill everyone. > [1023.430577] (1:Master@Jacquelin) Master done. > [1023.430577] (21:Slave 19@Provost) Received "Task_19". Processing it. diff --git a/examples/commTime/commtime.tesh b/examples/commTime/commtime.tesh index 0847b8b75a..c7bf972f21 100644 --- a/examples/commTime/commtime.tesh +++ b/examples/commTime/commtime.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar commTime/CommTimeTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/commTime/commTimeDeployment.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [7016.935689] [jmsg/INFO] Done running MSG_MAIN -> [7016.935689] [jmsg/INFO] MSG_main finished -> [7016.935689] [jmsg/INFO] Clean java world -> [7016.935689] [jmsg/INFO] Clean native world +> [7016.935689] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Bellemarre:commTime.Slave:(15) 0.000000] [jmsg/INFO] Receiving on 'slave_13' > [Bellemarre:commTime.Slave:(15) 7006.824050] [jmsg/INFO] Received Finalize. I'm done. See you! > [Boucherville:commTime.Slave:(18) 0.000000] [jmsg/INFO] Receiving on 'slave_16' diff --git a/examples/kademlia/kademlia.tesh b/examples/kademlia/kademlia.tesh index d2b2d3f4a0..739695617d 100644 --- a/examples/kademlia/kademlia.tesh +++ b/examples/kademlia/kademlia.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar kademlia/Kademlia ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/kademlia/kademlia.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [900.000000] [jmsg/INFO] Done running MSG_MAIN -> [900.000000] [jmsg/INFO] MSG_main finished -> [900.000000] [jmsg/INFO] Clean java world -> [900.000000] [jmsg/INFO] Clean native world +> [900.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Boivin:kademlia.Node:(2) 0.000000] [jmsg/INFO] Hi, I'm going to join the network with the id 1! > [Boivin:kademlia.Node:(2) 900.000000] [jmsg/INFO] 8/8 FIND_NODE have succedded. > [Jacquelin:kademlia.Node:(1) 0.000000] [jmsg/INFO] Hi, I'm going to create the network with the id 0! diff --git a/examples/master_slave_bypass/bypass.tesh b/examples/master_slave_bypass/bypass.tesh index aedfdd0888..dfcc347225 100644 --- a/examples/master_slave_bypass/bypass.tesh +++ b/examples/master_slave_bypass/bypass.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar master_slave_bypass/MsBypass ${srcdir:=.}/examples/master_slave_bypass/platform.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [0.013010] [jmsg/INFO] Done running MSG_MAIN -> [0.013010] [jmsg/INFO] MSG_main finished -> [0.013010] [jmsg/INFO] Clean java world -> [0.013010] [jmsg/INFO] Clean native world +> [0.013010] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [alice:process2:(2) 0.000000] [jmsg/INFO] Slave Hello! > [alice:process2:(2) 0.000000] [jmsg/INFO] Send finalize! > [bob:process1:(1) 0.000000] [jmsg/INFO] Master Hello! diff --git a/examples/master_slave_kill/kill.tesh b/examples/master_slave_kill/kill.tesh index 29de2ccea3..2c7179a93c 100644 --- a/examples/master_slave_kill/kill.tesh +++ b/examples/master_slave_kill/kill.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar master_slave_kill/MsKill ${srcdir:=.}/examples/master_slave_kill/platform.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [0.013010] [jmsg/INFO] Done running MSG_MAIN -> [0.013010] [jmsg/INFO] MSG_main finished -> [0.013010] [jmsg/INFO] Clean java world -> [0.013010] [jmsg/INFO] Clean native world +> [0.013010] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [alice:slave:(2) 0.000000] [jmsg/INFO] Slave Hello! > [alice:slave:(2) 0.000000] [jmsg/INFO] Send Mail1! > [bob:master:(1) 0.000000] [jmsg/INFO] Master Hello! diff --git a/examples/masterslave/masterslave.tesh b/examples/masterslave/masterslave.tesh index 9c7509d9f7..243f4c43a0 100644 --- a/examples/masterslave/masterslave.tesh +++ b/examples/masterslave/masterslave.tesh @@ -3,7 +3,6 @@ ! 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' @@ -27,10 +26,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar masterslave/Mastersl > [ 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] (0:@) MSG_main finished; Cleaning up the simulation... > [ 17.252217] (1:masterslave.Master@Jacquelin) Goodbye now! > [ 17.252217] (8:masterslave.Slave@Browne) Received Finalize. I'm done. See you! > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. diff --git a/examples/migration/migration.tesh b/examples/migration/migration.tesh index dc4c0cfefc..e40cb5041e 100644 --- a/examples/migration/migration.tesh +++ b/examples/migration/migration.tesh @@ -3,15 +3,11 @@ ! 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] (0:@) MSG_main finished; Cleaning up the simulation... > [ 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/mutualExclusion/mutualexclusion.tesh b/examples/mutualExclusion/mutualexclusion.tesh index 0ad11ff5a4..a8ca174e0c 100644 --- a/examples/mutualExclusion/mutualexclusion.tesh +++ b/examples/mutualExclusion/mutualexclusion.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar mutualExclusion/centralized/MutexCentral ${srcdir:=.}/examples/mutualExclusion/ring3.xml ${srcdir:=.}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [0.007806] [jmsg/INFO] Done running MSG_MAIN -> [0.007806] [jmsg/INFO] MSG_main finished -> [0.007806] [jmsg/INFO] Clean java world -> [0.007806] [jmsg/INFO] Clean native world +> [0.007806] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Host 0:mutualExclusion.centralized.Coordinator:(1) 0.001301] [jmsg/INFO] Got a request from mutualExclusion.centralized.Node. Queue empty: grant it > [Host 0:mutualExclusion.centralized.Coordinator:(1) 0.003903] [jmsg/INFO] Got a request from mutualExclusion.centralized.Node. Queue empty: grant it > [Host 0:mutualExclusion.centralized.Coordinator:(1) 0.007806] [jmsg/INFO] we should shutdown the simulation now diff --git a/examples/pingPong/pingpong.tesh b/examples/pingPong/pingpong.tesh index f8f28c34b3..cd4a7bf0ea 100644 --- a/examples/pingPong/pingpong.tesh +++ b/examples/pingPong/pingpong.tesh @@ -4,11 +4,7 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar pingPong/PingPongTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/pingPong/pingPongDeployment.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN -> [1.048890] [jmsg/INFO] Done running MSG_MAIN -> [1.048890] [jmsg/INFO] MSG_main finished -> [1.048890] [jmsg/INFO] Clean java world -> [1.048890] [jmsg/INFO] Clean native world +> [1.048890] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Boivin:pingPong.Receiver:(2) 0.000000] [jmsg/INFO] hello! > [Boivin:pingPong.Receiver:(2) 0.000000] [jmsg/INFO] try to get a task > [Boivin:pingPong.Receiver:(2) 1.048890] [jmsg/INFO] Got at time 1.0488895059341703 diff --git a/examples/priority/priority.tesh b/examples/priority/priority.tesh index 9d06d4e472..f7ff99b039 100644 --- a/examples/priority/priority.tesh +++ b/examples/priority/priority.tesh @@ -3,13 +3,9 @@ ! 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] (0:@) MSG_main finished; Cleaning up the simulation... > [ 1.111109] (1:priority.Test@Fafard) Goodbye now! > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. diff --git a/examples/startKillTime/startKillTime.tesh b/examples/startKillTime/startKillTime.tesh index c2e5816a93..edbe382bd8 100644 --- a/examples/startKillTime/startKillTime.tesh +++ b/examples/startKillTime/startKillTime.tesh @@ -1,7 +1,6 @@ #! ./tesh $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar startKillTime/StartKillTime ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/startKillTime/deployment_start_kill.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN > [Jacquelin:startKillTime.Master:(1) 0.000000] [jmsg/INFO] Hello! > [Boivin:startKillTime.Slave:(2) 1.000000] [jmsg/INFO] Hello! > [Jean_Yves:startKillTime.Slave:(3) 2.000000] [jmsg/INFO] Hello! @@ -9,7 +8,4 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar startKillTime/StartK > [Geoff:startKillTime.Slave:(5) 4.000000] [jmsg/INFO] Hello! > [Disney:startKillTime.Slave:(6) 5.000000] [jmsg/INFO] Hello! > [Jacquelin:startKillTime.Master:(1) 10.000000] [jmsg/INFO] OK, goodbye now. -> [10.000000] [jmsg/INFO] Done running MSG_MAIN -> [10.000000] [jmsg/INFO] MSG_main finished -> [10.000000] [jmsg/INFO] Clean java world -> [10.000000] [jmsg/INFO] Clean native world +> [10.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... diff --git a/examples/suspend/suspend.tesh b/examples/suspend/suspend.tesh index fce16e6a62..c6ec5f76a6 100644 --- a/examples/suspend/suspend.tesh +++ b/examples/suspend/suspend.tesh @@ -2,14 +2,10 @@ ! 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] (0:@) MSG_main finished; Cleaning up the simulation... > [ 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 ? diff --git a/examples/tracing/tracingPingPong.tesh b/examples/tracing/tracingPingPong.tesh index 850caa6e3c..50b5660ec0 100644 --- a/examples/tracing/tracingPingPong.tesh +++ b/examples/tracing/tracingPingPong.tesh @@ -4,14 +4,10 @@ $ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar tracing/TracingTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/tracing/tracingPingPongDeployment.xml --cfg=tracing:1 --cfg=tracing/filename:simulation.trace --cfg=tracing/platform:1 > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1' > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'simulation.trace' > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/platform' to '1' -> [4.474433] [jmsg/INFO] Done running MSG_MAIN -> [4.474433] [jmsg/INFO] MSG_main finished -> [4.474433] [jmsg/INFO] Clean java world -> [4.474433] [jmsg/INFO] Clean native world +> [4.474433] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... > [Boivin:tracing.Receiver:(2) 0.000000] [jmsg/INFO] hello! > [Boivin:tracing.Receiver:(2) 0.000000] [jmsg/INFO] try to get a task > [Boivin:tracing.Receiver:(2) 1.048890] [jmsg/INFO] Got at time 1.0488895059341703 diff --git a/org/simgrid/msg/Comm.java b/org/simgrid/msg/Comm.java index 66d264c51d..63e6d1e1db 100644 --- a/org/simgrid/msg/Comm.java +++ b/org/simgrid/msg/Comm.java @@ -83,6 +83,7 @@ public class Comm { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } } diff --git a/org/simgrid/msg/File.java b/org/simgrid/msg/File.java index fa42c6dfdf..9076bcf789 100644 --- a/org/simgrid/msg/File.java +++ b/org/simgrid/msg/File.java @@ -61,6 +61,7 @@ public class File { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } } \ No newline at end of file diff --git a/org/simgrid/msg/Host.java b/org/simgrid/msg/Host.java index 136f4b28df..4683f5dec6 100644 --- a/org/simgrid/msg/Host.java +++ b/org/simgrid/msg/Host.java @@ -83,7 +83,6 @@ public class Host { * This static method returns the count of the installed hosts. * * @return The count of the installed hosts. - * FIXME: Not implemented. */ public native static int getCount(); diff --git a/org/simgrid/msg/JniException.java b/org/simgrid/msg/JniException.java index 9edada6612..d9333a28e4 100644 --- a/org/simgrid/msg/JniException.java +++ b/org/simgrid/msg/JniException.java @@ -32,4 +32,7 @@ public class JniException extends RuntimeException { */ public JniException(String s) { super(s); } + public JniException(String string, Exception e) { + super(string,e); + } } diff --git a/org/simgrid/msg/Msg.java b/org/simgrid/msg/Msg.java index 4cbf037478..895fadf9e5 100644 --- a/org/simgrid/msg/Msg.java +++ b/org/simgrid/msg/Msg.java @@ -11,19 +11,106 @@ package org.simgrid.msg; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.File; + + public final class Msg { /* Statically load the library which contains all native functions used in here */ - static { + static private boolean isNativeInited = false; + public static void nativeInit() { + if (isNativeInited) + return; try { + /* prefer the version on disk, if existing */ System.loadLibrary("SG_java"); - } catch(UnsatisfiedLinkError e) { + } catch (UnsatisfiedLinkError e) { + /* If not found, unpack the one bundled into the jar file and use it */ + loadLib("simgrid"); + loadLib("SG_java"); + } + isNativeInited = true; + } + static { + nativeInit(); + } + private static void loadLib (String name) { + String Path = "NATIVE/"+System.getProperty("os.name")+"/"+System.getProperty("os.arch")+"/"; + String filename=name; + InputStream in = Msg.class.getClassLoader().getResourceAsStream(Path+filename); + + if (in == null) { + filename = "lib"+name+".so"; + in = Msg.class.getClassLoader().getResourceAsStream(Path+filename); + } + if (in == null) { + filename = name+".dll"; + in = Msg.class.getClassLoader().getResourceAsStream(Path+filename); + } + if (in == null) { + filename = "lib"+name+".dll"; + in = Msg.class.getClassLoader().getResourceAsStream(Path+filename); + } + if (in == null) { + filename = "lib"+name+".dylib"; + in = Msg.class.getClassLoader().getResourceAsStream(Path+filename); + } + if (in == null) { + throw new RuntimeException("Cannot find library "+name+" in path "+Path+". Sorry, but this jar does not seem to be usable on your machine."); + } +// Caching the file on disk: desactivated because it could fool the users +// if (new File(filename).isFile()) { +// // file was already unpacked -- use it directly +// System.load(new File(".").getAbsolutePath()+File.separator+filename); +// return; +// } + try { + // We must write the lib onto the disk before loading it -- stupid operating systems + File fileOut = new File(filename); +// if (!new File(".").canWrite()) { +// System.out.println("Cannot write in ."+File.separator+filename+"; unpacking the library into a temporary file instead"); + fileOut = File.createTempFile("simgrid-", ".tmp"); + // don't leak the file on disk, but remove it on JVM shutdown + Runtime.getRuntime().addShutdownHook(new Thread(new FileCleaner(fileOut.getAbsolutePath()))); +// } +// System.out.println("Unpacking SimGrid native library to " + fileOut.getAbsolutePath()); + OutputStream out = new FileOutputStream(fileOut); + + /* copy the library in position */ + byte[] buffer = new byte[4096]; + int bytes_read; + while ((bytes_read = in.read(buffer)) != -1) // Read until EOF + out.write(buffer, 0, bytes_read); + + /* close all file descriptors, and load that shit */ + in.close(); + out.close(); + System.load(fileOut.getAbsolutePath()); + } catch (Exception e) { System.err.println("Cannot load the bindings to the simgrid library: "); e.printStackTrace(); - System.err.println( - "Please check your LD_LIBRARY_PATH, or copy the simgrid and SG_java libraries to the current directory"); + System.err.println("This jar file does not seem to fit your system, sorry"); System.exit(1); } + } + /* A hackish mechanism used to remove the file containing our library when the JVM shuts down */ + private static class FileCleaner implements Runnable { + private String target; + public FileCleaner(String name) { + target = name; + } + public void run() { + try { + new File(target).delete(); + } catch(Exception e) { + System.out.println("Unable to clean temporary file "+target+" during shutdown."); + e.printStackTrace(); + } + } } + /** Retrieve the simulation time * @return */ diff --git a/org/simgrid/msg/Mutex.java b/org/simgrid/msg/Mutex.java index 7032b6e3ad..cb16ffb03f 100644 --- a/org/simgrid/msg/Mutex.java +++ b/org/simgrid/msg/Mutex.java @@ -31,6 +31,7 @@ public class Mutex { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } } diff --git a/org/simgrid/msg/Process.java b/org/simgrid/msg/Process.java index e8ed072546..edde2bf867 100644 --- a/org/simgrid/msg/Process.java +++ b/org/simgrid/msg/Process.java @@ -10,10 +10,7 @@ package org.simgrid.msg; import java.util.Arrays; -import java.util.Hashtable; import java.util.Vector; -import java.lang.Runnable; -import java.util.concurrent.Semaphore; /** * A process may be defined as a code, with some private data, executing @@ -404,6 +401,14 @@ public abstract class Process implements Runnable { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } + /** + * This static method returns the current amount of processes running + * + * @return The count of the running processes + */ + public native static int getCount(); + } diff --git a/org/simgrid/msg/RngStream.java b/org/simgrid/msg/RngStream.java index c9f54711b8..58b9c9e667 100644 --- a/org/simgrid/msg/RngStream.java +++ b/org/simgrid/msg/RngStream.java @@ -113,6 +113,7 @@ public class RngStream { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } } \ No newline at end of file diff --git a/org/simgrid/msg/Task.java b/org/simgrid/msg/Task.java index e5e5fbf543..59c103bcee 100644 --- a/org/simgrid/msg/Task.java +++ b/org/simgrid/msg/Task.java @@ -289,6 +289,7 @@ public class Task { */ public static native void nativeInit(); static { + Msg.nativeInit(); nativeInit(); } diff --git a/org/simgrid/trace/Trace.java b/org/simgrid/trace/Trace.java index ede59a5747..7943ed40cd 100644 --- a/org/simgrid/trace/Trace.java +++ b/org/simgrid/trace/Trace.java @@ -10,9 +10,12 @@ */ package org.simgrid.trace; +import org.simgrid.msg.Msg; + public final class Trace { /* Statically load the library which contains all native functions used in here */ static { + Msg.nativeInit(); try { System.loadLibrary("SG_java_tracing"); } catch(UnsatisfiedLinkError e) { diff --git a/src/jmsg.c b/src/jmsg.c index 97ba952549..41d7f36d0a 100644 --- a/src/jmsg.c +++ b/src/jmsg.c @@ -135,16 +135,14 @@ JNIEXPORT void JNICALL jobject jhost; /* Run everything */ - XBT_INFO("Ready to run MSG_MAIN"); + XBT_DEBUG("Ready to run MSG_MAIN"); rv = MSG_main(); - XBT_INFO("Done running MSG_MAIN"); + XBT_DEBUG("Done running MSG_MAIN"); jxbt_check_res("MSG_main()", rv, MSG_OK, bprintf ("unexpected error : MSG_main() failed .. please report this bug ")); - XBT_INFO("MSG_main finished"); - - XBT_INFO("Clean java world"); + XBT_INFO("MSG_main finished; Cleaning up the simulation..."); /* Cleanup java hosts */ hosts = MSG_hosts_as_dynar(); for (index = 0; index < xbt_dynar_length(hosts) - 1; index++) { @@ -154,7 +152,6 @@ JNIEXPORT void JNICALL } xbt_dynar_free(&hosts); - XBT_INFO("Clean native world"); } JNIEXPORT void JNICALL diff --git a/src/jmsg_process.c b/src/jmsg_process.c index 7773eeb1ea..aaa73e70ef 100644 --- a/src/jmsg_process.c +++ b/src/jmsg_process.c @@ -266,7 +266,8 @@ Java_org_simgrid_msg_Process_resume(JNIEnv * env, jxbt_check_res("MSG_process_resume()", rv, MSG_OK, bprintf("unexpected error , please report this bug")); } -JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart +JNIEXPORT void JNICALL +Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) { msg_process_t process = jprocess_to_native_process(jprocess, env); xbt_ex_t e; @@ -285,7 +286,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart xbt_ex_free(e); } } -JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart +JNIEXPORT void JNICALL +Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobject jprocess) { msg_process_t process = jprocess_to_native_process(jprocess, env); xbt_ex_t e; @@ -318,7 +320,8 @@ Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env, return (jboolean) MSG_process_is_suspended(process); } -JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep +JNIEXPORT void JNICALL +Java_org_simgrid_msg_Process_sleep (JNIEnv *env, jclass cls, jlong jmillis, jint jnanos) { double time = jmillis / 1000 + jnanos / 1000; @@ -398,3 +401,15 @@ Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdoubl msg_process_t process = jprocess_to_native_process(jprocess, env); MSG_process_set_kill_time(process, (double)jkilltime); } + +JNIEXPORT jint JNICALL +Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) { + /* FIXME: the next test on SimGrid version is to ensure that this still compiles with SG 3.8 while the C function were added in SG 3.9 only. + * This kind of pimple becomes mandatory when you get so slow to release the java version that it begins evolving further after the C release date. + */ +#if SIMGRID_VERSION >= 30900 + return (jint) MSG_process_get_number(); +#else + return (jint) -1; +#endif +} diff --git a/src/jmsg_process.h b/src/jmsg_process.h index cfc705139b..566a877ab1 100644 --- a/src/jmsg_process.h +++ b/src/jmsg_process.h @@ -261,4 +261,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *, jobject, jdouble); +JNIEXPORT jint JNICALL +Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls); + + #endif /* !MSG_JPROCESS_H */ diff --git a/src/smx_context_cojava.c b/src/smx_context_cojava.c index 4e43ef7694..00fe9b5db4 100644 --- a/src/smx_context_cojava.c +++ b/src/smx_context_cojava.c @@ -258,7 +258,24 @@ static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context) { 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."); + if (jcoroutine == NULL) { + FILE *conf= fopen("/proc/sys/vm/max_map_count","r"); + if (conf) { + int limit=-1; + fscanf(conf,"%d",&limit); + fclose(conf); + if (limit!=-1 && SIMIX_process_count() > (limit - 100) /2) + xbt_die("Error while creating a new coroutine. " + "This seem due to the the vm.max_map_count system limit that is only equal to %d while we already have %d coroutines. " + "Please check the install documentation to see how to increase this limit", limit, SIMIX_process_count()); + if (limit == -1) + xbt_die("Error while creating a new coroutine. " + "This seems to be a non-linux system, disabling the automatic verification that the system limit on the amount of memory maps is high enough."); + xbt_die("Error while creating a new coroutine. "); + } + + } + jcoroutine = (*env)->NewGlobalRef(env, jcoroutine); context->jcoroutine = jcoroutine; }