1 /* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u/Host.hpp"
7 #include "src/kernel/actor/ActorImpl.hpp"
8 #include "src/kernel/actor/SimcallObserver.hpp"
9 #include "src/kernel/context/Context.hpp"
10 #include "src/simix/popping_private.hpp"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(simix, "transmuting from user request into kernel handlers");
15 constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{
17 "Simcall::RUN_ANSWERED",
18 "Simcall::RUN_BLOCKING",
22 * @brief (in kernel mode) unpack the simcall and activate the handler
25 void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered)
27 XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_));
28 if (simcall_.observer_ != nullptr)
29 simcall_.observer_->prepare(times_considered);
30 if (context_->wannadie())
33 xbt_assert(simcall_.call_ != simgrid::simix::Simcall::NONE, "Asked to do the noop syscall on %s@%s", get_cname(),
34 get_host()->get_cname());
37 if (simcall_.call_ == simgrid::simix::Simcall::RUN_ANSWERED)
41 /** @brief returns a printable string representing a simcall */
42 const char* SIMIX_simcall_name(const s_smx_simcall& simcall)
44 if (simcall.observer_ != nullptr) {
45 static std::string name;
46 name = boost::core::demangle(typeid(*simcall.observer_).name());
47 const char* cname = name.c_str();
48 if (name.rfind("simgrid::kernel::", 0) == 0)
49 cname += 17; // strip prefix "simgrid::kernel::"
52 return simcall_names.at(static_cast<int>(simcall.call_));