From: Gabriel Corona Date: Tue, 15 Mar 2016 13:54:40 +0000 (+0100) Subject: [mc] Remove split the MCed and MCer part of MC_deadlock_check() X-Git-Tag: v3_13~417 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/56765019ed3cba9ccf83ac2a335c80988922ade7 [mc] Remove split the MCed and MCer part of MC_deadlock_check() --- diff --git a/src/mc/Client.cpp b/src/mc/Client.cpp index 38ebb687ab..fbbbe92c15 100644 --- a/src/mc/Client.cpp +++ b/src/mc/Client.cpp @@ -19,10 +19,10 @@ #include "src/mc/mc_protocol.h" #include "src/mc/Client.hpp" +#include "src/mc/mc_request.h" // We won't need those once the separation MCer/MCed is complete: #include "src/mc/mc_ignore.h" -#include "src/mc/mc_private.h" // MC_deadlock_check() #include "src/mc/mc_smx.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic"); @@ -93,10 +93,22 @@ void Client::handleMessages() case MC_MESSAGE_DEADLOCK_CHECK: { - int result = MC_deadlock_check(); + // Check deadlock: + bool deadlock = false; + smx_process_t process; + if (xbt_swag_size(simix_global->process_list)) { + deadlock = true; + xbt_swag_foreach(process, simix_global->process_list) + if (simgrid::mc::process_is_enabled(process)) { + deadlock = false; + break; + } + } + + // Send result: s_mc_int_message_t answer; answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY; - answer.value = result; + answer.value = deadlock; if (channel_.send(answer)) xbt_die("Could not send response"); } diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index 4489b8473e..ca77039b80 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -437,5 +437,24 @@ void ModelChecker::simcall_handle(simgrid::mc::Process& process, unsigned long p return; } +bool ModelChecker::checkDeadlock() +{ + int res; + if ((res = this->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK))) + xbt_die("Could not check deadlock state"); + s_mc_int_message_t message; + ssize_t s = mc_model_checker->process().getChannel().receive(message); + if (s == -1) + xbt_die("Could not receive message"); + if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) + xbt_die("%s received unexpected message %s (%i, size=%i) " + "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)", + MC_mode_name(mc_mode), + MC_message_type_name(message.type), (int) message.type, (int) s, + (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message) + ); + return message.value != 0; +} + } } diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index 7babe6a6ea..9bde129c7d 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -71,6 +71,9 @@ public: mc_model_checker->wait_client(mc_model_checker->process()); } void exit(int status); + + bool checkDeadlock(); + private: void setup_ignore(); bool handle_message(char* buffer, ssize_t size); diff --git a/src/mc/mc_comm_determinism.cpp b/src/mc/mc_comm_determinism.cpp index 4cca3ce387..0ed9c5795c 100644 --- a/src/mc/mc_comm_determinism.cpp +++ b/src/mc/mc_comm_determinism.cpp @@ -432,7 +432,7 @@ static int MC_modelcheck_comm_determinism_main(void) visited_state = nullptr; /* Check for deadlocks */ - if (MC_deadlock_check()) { + if (mc_model_checker->checkDeadlock()) { MC_show_deadlock(nullptr); return SIMGRID_MC_EXIT_DEADLOCK; } diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index f3d14ae732..2c40f43e26 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -133,41 +133,6 @@ void MC_exit(void) //xbt_abort(); } -#if HAVE_MC -int MC_deadlock_check() -{ - if (mc_mode == MC_MODE_SERVER) { - int res; - if ((res = mc_model_checker->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK))) - xbt_die("Could not check deadlock state"); - s_mc_int_message_t message; - ssize_t s = mc_model_checker->process().getChannel().receive(message); - if (s == -1) - xbt_die("Could not receive message"); - if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) - xbt_die("%s received unexpected message %s (%i, size=%i) " - "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)", - MC_mode_name(mc_mode), - MC_message_type_name(message.type), (int) message.type, (int) s, - (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message) - ); - return message.value; - } - - bool deadlock = false; - smx_process_t process; - if (xbt_swag_size(simix_global->process_list)) { - deadlock = true; - xbt_swag_foreach(process, simix_global->process_list) - if (simgrid::mc::process_is_enabled(process)) { - deadlock = false; - break; - } - } - return deadlock; -} -#endif - /** * \brief Re-executes from the state at position start all the transitions indicated by * a given model-checker stack. diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 5045c9f737..869042cdf6 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -47,7 +47,6 @@ XBT_PRIVATE extern FILE *dot_output; XBT_PRIVATE extern int user_max_depth_reached; -XBT_PRIVATE int MC_deadlock_check(void); XBT_PRIVATE void MC_replay(xbt_fifo_t stack); XBT_PRIVATE void MC_replay_liveness(xbt_fifo_t stack); XBT_PRIVATE void MC_show_deadlock(smx_simcall_t req); diff --git a/src/mc/mc_safety.cpp b/src/mc/mc_safety.cpp index b9ffea3dc0..62cb15cba8 100644 --- a/src/mc/mc_safety.cpp +++ b/src/mc/mc_safety.cpp @@ -180,7 +180,7 @@ int modelcheck_safety(void) visited_state = nullptr; /* Check for deadlocks */ - if (MC_deadlock_check()) { + if (mc_model_checker->checkDeadlock()) { MC_show_deadlock(nullptr); return SIMGRID_MC_EXIT_DEADLOCK; }