Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change order of initialization.
authorAugustin Degomme <augustin.degomme@imag.fr>
Tue, 6 Jan 2015 14:14:01 +0000 (15:14 +0100)
committerAugustin Degomme <augustin.degomme@imag.fr>
Tue, 6 Jan 2015 14:14:01 +0000 (15:14 +0100)
If the cpumodel is constructed before msg init is called, a log message is sent without proper init
This meant undefined behavior, and in one particular case the wrong locale being selected, the message used a comma as a separator instead of a dot.
There was a big hint in the comment just before : "do not do anything before the msg.init call !"

examples/java/surfCpuModel/TestCpuModel.java
examples/java/surfCpuModel/surf_cpu_model.tesh

index 5dc900f..068cb8f 100644 (file)
@@ -21,11 +21,11 @@ public class TestCpuModel {
 
   public static void main(String[] args) throws NativeException {
     /* initialize the MSG simulation. Must be done before anything else (even logging). */
+    Msg.init(args);
+    
     CpuConstantModel cm = new CpuConstantModel();
     Surf.setCpuModel(cm);
 
-    Msg.init(args);
-
     if(args.length < 2) {
       Msg.info("Usage   : TestPlugin platform_file deployment_file");
       Msg.info("example : TestPlugin ping_pong_platform.xml ping_pong_deployment.xml");
index ce1c446..596d2bc 100644 (file)
@@ -1,9 +1,9 @@
 #! tesh
 
 $ java -classpath ${classpath:=.} surfCpuModel/TestCpuModel ${srcdir:=.}/../platforms/small_platform.xml ${srcdir:=.}/surfCpuModel/surfCpuModelDeployment.xml --cfg=workstation/model:compound
-> [0.000000] [jmsg/INFO] Initialize Cpu Constant Model
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'workstation/model' to 'compound'
 > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
+> [0.000000] [jmsg/INFO] Initialize Cpu Constant Model
 > [0.000000] [jmsg/INFO] New Cpu(Tremblay, 9.8095E7, 1.0)
 > [0.000000] [jmsg/INFO] New Cpu(Jupiter, 7.6296E7, 1.0)
 > [0.000000] [jmsg/INFO] New Cpu(Fafard, 7.6296E7, 1.0)