Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : add example (electric_fence) to check the soundness of the verificati...
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 27 Mar 2013 12:17:43 +0000 (13:17 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 27 Mar 2013 12:22:32 +0000 (13:22 +0100)
examples/msg/mc/CMakeLists.txt
examples/msg/mc/deploy_electric_fence.xml [moved from examples/msg/mc/deploy_random_test.xml with 71% similarity]
examples/msg/mc/electric_fence.c [new file with mode: 0644]
examples/msg/mc/random_test.c [deleted file]

index d9765bc..e6932b4 100644 (file)
@@ -10,6 +10,7 @@ if(HAVE_MC)
   add_executable(bugged1     bugged1.c)
   add_executable(bugged2      bugged2.c)
   add_executable(bugged3          bugged3.c)
+  add_executable(electric_fence           electric_fence.c)
   add_executable(bugged1_liveness bugged1_liveness.c)
   add_executable(bugged2_liveness bugged2_liveness.c)
   add_executable(chord/chord_liveness chord/chord_liveness.c)
@@ -23,6 +24,7 @@ if(HAVE_MC)
   target_link_libraries(bugged1     simgrid )
   target_link_libraries(bugged2     simgrid )
   target_link_libraries(bugged3     simgrid )
+  target_link_libraries(electric_fence     simgrid )
   target_link_libraries(bugged1_liveness     simgrid )
   target_link_libraries(bugged2_liveness     simgrid )
   target_link_libraries(chord/chord_liveness     simgrid )
@@ -54,8 +56,8 @@ set(xml_files
   ${CMAKE_CURRENT_SOURCE_DIR}/deploy_bugged2_liveness.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deploy_bugged2.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deploy_bugged3.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/deploy_electric_fence.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deploy_mutex.xml
-  ${CMAKE_CURRENT_SOURCE_DIR}/deploy_random_test.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/chord/deploy_chord_liveness.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/test/deploy_snapshot_comparison.xml
@@ -69,6 +71,7 @@ set(examples_src
   ${CMAKE_CURRENT_SOURCE_DIR}/bugged2.c
   ${CMAKE_CURRENT_SOURCE_DIR}/bugged2_liveness.c
   ${CMAKE_CURRENT_SOURCE_DIR}/bugged3.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/electric_fence.c
   ${CMAKE_CURRENT_SOURCE_DIR}/centralized_mutex.c
   ${CMAKE_CURRENT_SOURCE_DIR}/bugged1_liveness.h
   ${CMAKE_CURRENT_SOURCE_DIR}/bugged2_liveness.h
similarity index 71%
rename from examples/msg/mc/deploy_random_test.xml
rename to examples/msg/mc/deploy_electric_fence.xml
index 31415a5..3fd4d5a 100644 (file)
@@ -4,14 +4,10 @@
   <process host="HostA" function="server">
     <argument value="0"/>
   </process>
-  <process host="HostB" function="server">
-    <argument value="0"/>
-  </process>
-
-<!--  <process host="HostB" function="client">
+  <process host="HostB" function="client">
     <argument value="1"/>
   </process>  
   <process host="HostC" function="client">
     <argument value="2"/>
-  </process> -->
+  </process>
 </platform>
diff --git a/examples/msg/mc/electric_fence.c b/examples/msg/mc/electric_fence.c
new file mode 100644 (file)
index 0000000..cfe23b7
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (c) 2013. 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. */
+
+
+/******************** Non-deterministic message ordering  *********************/
+/* This example implements one process which receives messages from two other */
+/* processes. There is no bug on it, it is just provided to test the soundness*/ 
+/* of the state space reduction with DPOR, if the maximum depth (defined with */
+/* --cfg=model-check/max_depth:) is reached.                                  */
+/******************************************************************************/
+
+#include <msg/msg.h>
+#include <simgrid/modelchecker.h>
+
+#define N 2
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(electric_fence, "Example to check the soundness of DPOR");
+
+int server(int argc, char *argv[]);
+int client(int argc, char *argv[]);
+
+int server(int argc, char *argv[])
+{
+  msg_task_t task1 = NULL, task2 = NULL;
+  msg_comm_t comm_received1 = NULL, comm_received2 = NULL;
+
+  comm_received1 = MSG_task_irecv(&task1, "mymailbox");
+  comm_received2 = MSG_task_irecv(&task2, "mymailbox");
+
+  MSG_comm_wait(comm_received1, -1);
+  MSG_comm_wait(comm_received2, -1);
+
+  XBT_INFO("OK");
+  return 0;
+}
+
+int client(int argc, char *argv[])
+{
+
+  msg_task_t task = MSG_task_create(argv[1], 0, 10000, NULL);
+
+  MSG_task_send(task, "mymailbox");
+  
+  XBT_INFO("Sent!");
+  return 0;
+}
+
+int main(int argc, char *argv[])
+{
+
+  MSG_init(&argc, argv);
+
+  MSG_create_environment("platform.xml");
+
+  MSG_function_register("server", server);
+
+  MSG_function_register("client", client);
+
+  MSG_launch_application("deploy_electric_fence.xml");
+
+  MSG_main();
+
+  return 0;
+
+}
diff --git a/examples/msg/mc/random_test.c b/examples/msg/mc/random_test.c
deleted file mode 100644 (file)
index 8814bdf..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <msg/msg.h>
-#include <simgrid/modelchecker.h>
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(random_test, "Random Test");
-
-int server(int argc, char *argv[]);
-
-int server(int argc, char *argv[])
-{
-  int val;
-  val = MC_random(3, 6);
-  XBT_INFO("val=%d", val);
-  XBT_INFO("OK");
-  return 0;
-}
-
-int main(int argc, char *argv[])
-{
-  MSG_init(&argc, argv);
-
-  MSG_create_environment("platform.xml");
-
-  MSG_function_register("server", server);
-
-//  MSG_function_register("client", client);
-
-  MSG_launch_application("deploy_random_test.xml");
-
-  MSG_main();
-
-  return 0;
-}