X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d0db566319780080d97b6b0e66717959b42ff228..a511865336e83ac3654632265ed00b8f0bf0eccc:/src/mc/Client.cpp diff --git a/src/mc/Client.cpp b/src/mc/Client.cpp index 38ebb687ab..cf7398d255 100644 --- a/src/mc/Client.cpp +++ b/src/mc/Client.cpp @@ -14,15 +14,18 @@ #include #include #include +#include + +#include #include "src/internal_config.h" #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"); @@ -43,10 +46,7 @@ Client* Client::initialize() if (client_) return client_.get(); - // Check and set the mode: - if (mc_mode != MC_MODE_NONE) - abort(); - mc_mode = MC_MODE_CLIENT; + _sg_do_model_check = 1; // Fetch socket from MC_ENV_SOCKET_FD: char* fd_env = std::getenv(MC_ENV_SOCKET_FD); @@ -67,7 +67,7 @@ Client* Client::initialize() client_ = std::unique_ptr(new simgrid::mc::Client(fd)); // Wait for the model-checker: - if (ptrace(PTRACE_TRACEME, 0, nullptr, NULL) == -1 || raise(SIGSTOP) != 0) + if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1 || raise(SIGSTOP) != 0) xbt_die("Could not wait for the model-checker"); client_->handleMessages(); @@ -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"); } @@ -131,8 +143,7 @@ void Client::handleMessages() break; default: - xbt_die("%s received unexpected message %s (%i)", - MC_mode_name(mc_mode), + xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message.type), message.type ); @@ -143,10 +154,10 @@ void Client::handleMessages() void Client::mainLoop(void) { while (1) { + simgrid::mc::wait_for_requests(); if (channel_.send(MC_MESSAGE_WAITING)) xbt_die("Could not send WAITING mesage to model-checker"); this->handleMessages(); - simgrid::mc::wait_for_requests(); } }