+
+void RemoteApp::wait_for_requests()
+{
+ /* Resume the application */
+ if (model_checker_->get_channel().send(MessageType::CONTINUE) != 0)
+ throw xbt::errno_error();
+ get_remote_process_memory().clear_cache();
+
+ if (this->get_remote_process_memory().running())
+ model_checker_->channel_handle_events();
+}
+
+void RemoteApp::shutdown()
+{
+ XBT_DEBUG("Shutting down model-checker");
+
+ RemoteProcessMemory& process = get_remote_process_memory();
+ if (process.running()) {
+ XBT_DEBUG("Killing process");
+ finalize_app(true);
+ kill(process.pid(), SIGKILL);
+ process.terminate();
+ }
+}
+
+Transition* RemoteApp::handle_simcall(aid_t aid, int times_considered, bool new_transition)
+{
+ s_mc_message_simcall_execute_t m = {};
+ m.type = MessageType::SIMCALL_EXECUTE;
+ m.aid_ = aid;
+ m.times_considered_ = times_considered;
+ model_checker_->get_channel().send(m);
+
+ get_remote_process_memory().clear_cache();
+ if (this->get_remote_process_memory().running())
+ model_checker_->channel_handle_events(); // The app may send messages while processing the transition
+
+ s_mc_message_simcall_execute_answer_t answer;
+ ssize_t s = model_checker_->get_channel().receive(answer);
+ xbt_assert(s != -1, "Could not receive message");
+ xbt_assert(s == sizeof answer, "Broken message (size=%zd; expected %zu)", s, sizeof answer);
+ xbt_assert(answer.type == MessageType::SIMCALL_EXECUTE_ANSWER,
+ "Received unexpected message %s (%i); expected MessageType::SIMCALL_EXECUTE_ANSWER (%i)",
+ to_c_str(answer.type), (int)answer.type, (int)MessageType::SIMCALL_EXECUTE_ANSWER);
+
+ if (new_transition) {
+ std::stringstream stream(answer.buffer.data());
+ return deserialize_transition(aid, times_considered, stream);
+ } else
+ return nullptr;
+}
+
+void RemoteApp::finalize_app(bool terminate_asap)
+{
+ s_mc_message_int_t m = {};
+ m.type = MessageType::FINALIZE;
+ m.value = terminate_asap;
+ xbt_assert(model_checker_->get_channel().send(m) == 0, "Could not ask the app to finalize on need");
+
+ s_mc_message_t answer;
+ ssize_t s = model_checker_->get_channel().receive(answer);
+ xbt_assert(s != -1, "Could not receive answer to FINALIZE");
+ xbt_assert(s == sizeof answer, "Broken message (size=%zd; expected %zu)", s, sizeof answer);
+ xbt_assert(answer.type == MessageType::FINALIZE_REPLY,
+ "Received unexpected message %s (%i); expected MessageType::FINALIZE_REPLY (%i)", to_c_str(answer.type),
+ (int)answer.type, (int)MessageType::FINALIZE_REPLY);
+}
+