From 466ff3342641c55771c2eea2a46ec476e42579eb Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 6 Jan 2015 15:14:01 +0100 Subject: [PATCH] Change order of initialization. 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 | 4 ++-- examples/java/surfCpuModel/surf_cpu_model.tesh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/java/surfCpuModel/TestCpuModel.java b/examples/java/surfCpuModel/TestCpuModel.java index 5dc900f945..068cb8fa57 100644 --- a/examples/java/surfCpuModel/TestCpuModel.java +++ b/examples/java/surfCpuModel/TestCpuModel.java @@ -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"); diff --git a/examples/java/surfCpuModel/surf_cpu_model.tesh b/examples/java/surfCpuModel/surf_cpu_model.tesh index ce1c446e35..596d2bcf85 100644 --- a/examples/java/surfCpuModel/surf_cpu_model.tesh +++ b/examples/java/surfCpuModel/surf_cpu_model.tesh @@ -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) -- 2.20.1