1 /* Copyright (c) 2016-2023. 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/Exception.hpp>
7 #include <simgrid/kernel/Timer.hpp>
8 #include <simgrid/kernel/routing/NetPoint.hpp>
9 #include <simgrid/kernel/routing/NetZoneImpl.hpp>
10 #include <simgrid/s4u/Host.hpp>
12 #include "src/kernel/EngineImpl.hpp"
13 #include "src/kernel/resource/StandardLinkImpl.hpp"
14 #include "src/kernel/resource/profile/Profile.hpp"
15 #include "src/kernel/xml/platf.hpp"
16 #include "src/mc/mc.h"
17 #include "src/mc/mc_config.hpp"
18 #include "src/mc/mc_record.hpp"
19 #include "src/mc/mc_replay.hpp"
20 #include "src/simgrid/math_utils.h"
21 #include "src/simgrid/sg_config.hpp"
22 #include "src/smpi/include/smpi_actor.hpp"
25 #include "src/mc/remote/AppSide.hpp"
28 #include "xbt/log.hpp"
30 #include <boost/algorithm/string/predicate.hpp>
33 XBT_LOG_NEW_DEFAULT_CATEGORY(ker_engine, "Logging specific to Engine (kernel)");
35 namespace simgrid::kernel {
36 double EngineImpl::now_ = 0.0;
37 EngineImpl* EngineImpl::instance_ = nullptr; /* That singleton is awful too. */
39 config::Flag<double> cfg_breakpoint{"debug/breakpoint",
40 "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
41 config::Flag<bool> cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true};
43 constexpr std::initializer_list<std::pair<const char*, context::ContextFactory* (*)()>> context_factories = {
45 {"raw", &context::raw_factory},
47 #if HAVE_UCONTEXT_CONTEXTS
48 {"ucontext", &context::sysv_factory},
50 #if HAVE_BOOST_CONTEXTS
51 {"boost", &context::boost_factory},
53 {"thread", &context::thread_factory},
56 static_assert(context_factories.size() > 0, "No context factories are enabled for this build");
58 // Create the list of possible contexts:
59 static inline std::string contexts_list()
63 for (auto const& [factory_name, _] : context_factories) {
64 res += sep + factory_name;
70 static config::Flag<std::string> context_factory_name("contexts/factory",
71 ("Possible values: " + contexts_list()).c_str(),
72 context_factories.begin()->first);
74 } // namespace simgrid::kernel
76 XBT_ATTRIB_NORETURN static void inthandler(int)
78 if (simgrid::kernel::cfg_verbose_exit) {
79 XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option "
80 "'debug/verbose-exit').");
81 simgrid::kernel::EngineImpl::get_instance()->display_all_actor_status();
83 XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false.");
88 static void segvhandler(int signum, siginfo_t* siginfo, void* /*context*/)
90 if ((siginfo->si_signo == SIGSEGV && siginfo->si_code == SEGV_ACCERR) || siginfo->si_signo == SIGBUS) {
92 "Access violation or Bus error detected.\n"
93 "This probably comes from a programming error in your code, or from a stack\n"
94 "overflow. If you are certain of your code, try increasing the stack size\n"
95 " --cfg=contexts/stack-size:XXX (current size is %u KiB).\n"
97 "If it does not help, this may have one of the following causes:\n"
98 "a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n"
99 "Failing hardware can sometimes generate such errors too.\n"
101 "If you think you've found a bug in SimGrid, please report it along with a\n"
102 "Minimal Working Example (MWE) reproducing your problem and a full backtrace\n"
103 "of the fault captured with gdb or valgrind.\n",
104 simgrid::kernel::context::Context::stack_size / 1024);
105 } else if (siginfo->si_signo == SIGSEGV) {
106 fprintf(stderr, "Segmentation fault.\n");
108 if (SMPI_is_inited() && smpi_cfg_privatization() == SmpiPrivStrategies::NONE) {
109 #if HAVE_PRIVATIZATION
110 fprintf(stderr, "Try to enable SMPI variable privatization with --cfg=smpi/privatization:yes.\n");
112 fprintf(stderr, "Sadly, your system does not support --cfg=smpi/privatization:yes (yet).\n");
113 #endif /* HAVE_PRIVATIZATION */
115 #endif /* HAVE_SMPI */
120 static void install_signal_handlers()
122 /* Install signal handler for SIGINT */
123 std::signal(SIGINT, inthandler);
125 /* Install signal handler for SIGSEGV */
126 if (simgrid::kernel::context::Context::install_sigsegv_stack(true) == -1) {
127 XBT_WARN("Failed to register alternate signal stack: %s", strerror(errno));
131 struct sigaction action;
132 action.sa_sigaction = &segvhandler;
133 action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
134 sigemptyset(&action.sa_mask);
136 /* Linux tend to raise only SIGSEGV where other systems also raise SIGBUS on severe error */
137 for (int sig : {SIGSEGV, SIGBUS}) {
138 if (sigaction(sig, &action, nullptr) == -1)
139 XBT_WARN("Failed to register signal handler for signal %d: %s", sig, strerror(errno));
143 static simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
144 "debug/clean-atexit", "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.", true};
146 namespace simgrid::kernel {
148 EngineImpl::~EngineImpl()
150 /* Also delete the other data */
151 delete netzone_root_;
152 for (auto const& [_, netpoint] : netpoints_)
155 for (auto const& [_, mailbox] : mailboxes_)
158 for (auto const& [_, queue] : mqueues_)
161 /* Kill all actors (but maestro) */
162 maestro_->kill_all();
167 delete context_factory_;
169 /* clear models before freeing handle, network models can use external callback defined in the handle */
170 models_prio_.clear();
173 void EngineImpl::initialize(int* argc, char** argv)
175 xbt_assert(EngineImpl::instance_ == nullptr,
176 "It is currently forbidden to create more than one instance of kernel::EngineImpl");
177 EngineImpl::instance_ = this;
179 // The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
180 // layers. But instance_ needs to be created, as we send the address of some of its fields to the MC that wants to
181 // read them directly.
182 simgrid::mc::AppSide::get(); // To ensure that it's initialized
185 if (static bool inited = false; not inited) {
187 xbt_log_init(argc, argv);
189 simgrid::xbt::install_exception_handler();
191 sg_config_init(argc, argv);
194 cmdline_.assign(argv, argv + *argc);
196 instance_->context_mod_init();
198 install_signal_handlers();
200 if (cfg_dbg_clean_atexit)
204 void EngineImpl::context_mod_init() const
206 xbt_assert(not instance_->has_context_factory());
208 #if HAVE_SMPI && defined(__NetBSD__)
209 smpi_init_options_internal(false);
210 std::string priv = config::get_value<std::string>("smpi/privatization");
211 if (context_factory_name == "thread" && (priv == "dlopen" || priv == "yes" || priv == "default" || priv == "1")) {
212 XBT_WARN("dlopen+thread broken on Apple and BSD. Switching to raw contexts.");
213 context_factory_name = "raw";
217 #if HAVE_SMPI && defined(__FreeBSD__)
218 smpi_init_options_internal(false);
219 if (context_factory_name == "thread" && config::get_value<std::string>("smpi/privatization") != "no") {
220 XBT_WARN("mmap broken on FreeBSD, but dlopen+thread broken too. Switching to dlopen+raw contexts.");
221 context_factory_name = "raw";
225 /* use the factory specified by --cfg=contexts/factory:value */
226 for (auto const& [factory_name, factory] : context_factories)
227 if (context_factory_name == factory_name) {
228 instance_->set_context_factory(factory());
232 if (not instance_->has_context_factory()) {
233 XBT_ERROR("Invalid context factory specified. Valid factories on this machine:");
234 #if HAVE_RAW_CONTEXTS
235 XBT_ERROR(" raw: high performance context factory implemented specifically for SimGrid");
237 XBT_ERROR(" (raw contexts were disabled at compilation time on this machine -- check configure logs for details)");
239 #if HAVE_UCONTEXT_CONTEXTS
240 XBT_ERROR(" ucontext: classical system V contexts (implemented with makecontext, swapcontext and friends)");
242 XBT_ERROR(" (ucontext was disabled at compilation time on this machine -- check configure logs for details)");
244 #if HAVE_BOOST_CONTEXTS
245 XBT_ERROR(" boost: this uses the boost libraries context implementation");
247 XBT_ERROR(" (boost was disabled at compilation time on this machine -- check configure logs for details. Did you "
248 "install the libboost-context-dev package?)");
250 XBT_ERROR(" thread: slow portability layer using standard threads as provided by libstdc");
251 xbt_die("Please use a valid factory.");
255 void EngineImpl::shutdown()
257 if (EngineImpl::instance_ == nullptr)
259 XBT_DEBUG("EngineImpl::shutdown() called. Simulation's over.");
261 if (not instance_->actor_list_.empty()) {
262 if (smpi_process() && smpi_process()->initialized()) {
263 xbt_die("Process exited without calling MPI_Finalize - Killing simulation");
265 XBT_WARN("Process called exit when leaving - Skipping cleanups");
271 if (instance_->has_actors_to_run() && simgrid_get_clock() <= 0.0) {
273 XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
274 XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
275 xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
278 while (not timer::kernel_timers().empty()) {
279 delete timer::kernel_timers().top().second;
280 timer::kernel_timers().pop();
284 sg_platf_parser_finalize();
290 void EngineImpl::seal_platform() const
293 static bool sealed = false;
298 /* seal netzone root, recursively seal children netzones, hosts and disks */
299 netzone_root_->seal();
302 void EngineImpl::load_platform(const std::string& platf)
304 double start = xbt_os_time();
305 if (boost::algorithm::ends_with(platf, ".so") || boost::algorithm::ends_with(platf, ".dylib")) {
306 void* handle = dlopen(platf.c_str(), RTLD_LAZY);
307 xbt_assert(handle, "Impossible to open platform file: %s", platf.c_str());
308 platf_handle_ = std::unique_ptr<void, std::function<int(void*)>>(handle, dlclose);
309 using load_fct_t = void (*)(const simgrid::s4u::Engine&);
310 auto callable = (load_fct_t)dlsym(platf_handle_.get(), "load_platform");
311 const char* dlsym_error = dlerror();
312 xbt_assert(not dlsym_error, "Error: %s", dlsym_error);
313 callable(*simgrid::s4u::Engine::get_instance());
315 parse_platform_file(platf);
318 double end = xbt_os_time();
319 XBT_DEBUG("PARSE TIME: %g", (end - start));
322 void EngineImpl::load_deployment(const std::string& file) const
324 sg_platf_parser_finalize();
326 simgrid_parse_open(file);
327 simgrid_parse(false);
328 simgrid_parse_close();
331 void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
333 registered_functions[name] = code;
335 void EngineImpl::register_default(const actor::ActorCodeFactory& code)
337 default_function = code;
340 void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::vector<resource::Model*>& dependencies)
342 auto model_name = model->get_name();
343 xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
344 "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
346 for (const auto* dep : dependencies) {
347 xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
348 "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
350 models_.push_back(model.get());
351 models_prio_[model_name] = std::move(model);
354 /** Wake up all actors waiting for an action to finish */
355 void EngineImpl::handle_ended_actions() const
357 for (auto const& model : models_) {
358 XBT_DEBUG("Handling the failed actions (if any)");
359 while (auto* action = model->extract_failed_action()) {
360 XBT_DEBUG(" Handling Action %p", action);
361 if (action->get_activity() != nullptr) { // Skip vcpu actions
362 activity::ActivityImplPtr activity(action->get_activity());
363 // Action failures are not automatically reported when the action is started by maestro (as in SimDAG)
364 if (activity->get_actor() == maestro_)
365 activity->get_iface()->complete(s4u::Activity::State::FAILED);
370 XBT_DEBUG("Handling the terminated actions (if any)");
371 while (auto* action = model->extract_done_action()) {
372 XBT_DEBUG(" Handling Action %p", action);
373 if (action->get_activity() != nullptr) {
374 activity::ActivityImplPtr activity(action->get_activity());
376 // Action termination are not automatically reported when the action is started by maestro (as in SimDAG)
377 activity->set_finish_time(action->get_finish_time());
379 if (activity->get_actor() == maestro_)
380 activity->get_iface()->complete(s4u::Activity::State::FINISHED);
388 * @brief Executes the actors in actors_to_run.
390 * The actors in actors_to_run are run (in parallel if possible). On exit, actors_to_run is empty, and actors_that_ran
391 * contains the list of actors that just ran. The two lists are swapped so, be careful when using them before and after
392 * a call to this function.
394 void EngineImpl::run_all_actors()
396 instance_->get_context_factory()->run_all(actors_to_run_);
398 for (auto const& actor : actors_to_run_)
399 if (actor->to_be_freed())
400 actor->cleanup_from_kernel();
402 actors_to_run_.swap(actors_that_ran_);
403 actors_to_run_.clear();
406 actor::ActorImpl* EngineImpl::get_actor_by_pid(aid_t pid)
408 auto item = actor_list_.find(pid);
409 return item == actor_list_.end() ? nullptr : item->second;
412 void EngineImpl::remove_daemon(actor::ActorImpl* actor)
414 auto it = daemons_.find(actor);
415 xbt_assert(it != daemons_.end(), "The dying daemon is not a daemon after all. Please report that bug.");
419 void EngineImpl::add_actor_to_run_list_no_check(actor::ActorImpl* actor)
421 XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
422 actors_to_run_.push_back(actor);
425 void EngineImpl::add_actor_to_run_list(actor::ActorImpl* actor)
427 if (std::find(begin(actors_to_run_), end(actors_to_run_), actor) != end(actors_to_run_)) {
428 XBT_DEBUG("Actor %s is already in the to_run list", actor->get_cname());
430 XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
431 actors_to_run_.push_back(actor);
434 void EngineImpl::empty_trash()
436 while (not actors_to_destroy_.empty()) {
437 actor::ActorImpl* actor = &actors_to_destroy_.front();
438 actors_to_destroy_.pop_front();
439 XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
440 intrusive_ptr_release(actor);
444 void EngineImpl::display_all_actor_status() const
446 XBT_INFO("%zu actors are still running, waiting for something.", actor_list_.size());
447 /* List the actors and their state */
448 XBT_INFO("Legend of the following listing: \"Actor <pid> (<name>@<host>): <status>\"");
449 for (auto const& [_, actor] : actor_list_) {
450 if (actor->waiting_synchro_) {
451 const char* synchro_description = "unknown";
453 if (boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(actor->waiting_synchro_) != nullptr)
454 synchro_description = "execution";
456 if (boost::dynamic_pointer_cast<kernel::activity::CommImpl>(actor->waiting_synchro_) != nullptr)
457 synchro_description = "communication";
459 if (boost::dynamic_pointer_cast<kernel::activity::MessImpl>(actor->waiting_synchro_) != nullptr)
460 synchro_description = "message";
462 if (boost::dynamic_pointer_cast<kernel::activity::SleepImpl>(actor->waiting_synchro_) != nullptr)
463 synchro_description = "sleeping";
465 if (boost::dynamic_pointer_cast<kernel::activity::SynchroImpl>(actor->waiting_synchro_) != nullptr)
466 synchro_description = "synchronization";
468 if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro_) != nullptr)
469 synchro_description = "I/O";
471 XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %s to finish %s", actor->get_pid(),
472 actor->get_cname(), actor->get_host()->get_cname(), synchro_description,
473 (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()),
474 actor->waiting_synchro_->get_cname(), actor->waiting_synchro_->get_state_str(),
475 (actor->simcall_.observer_ != nullptr && not xbt_log_no_loc
476 ? actor->simcall_.observer_->to_string().c_str()
479 XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(),
480 (actor->simcall_.observer_ != nullptr ? actor->simcall_.observer_->to_string().c_str()
481 : actor->simcall_.get_cname()));
486 double EngineImpl::solve(double max_date) const
488 double time_delta = -1.0; /* duration */
490 resource::Resource* resource = nullptr;
492 if (max_date != -1.0) {
493 xbt_assert(max_date >= now_, "You asked to simulate up to %f, but that's in the past already", max_date);
495 time_delta = max_date - now_;
498 XBT_DEBUG("Looking for next event in all models");
499 for (auto* model : models_) {
500 if (not model->next_occurring_event_is_idempotent())
503 double next_event = model->next_occurring_event(now_);
504 if ((time_delta < 0.0 || next_event < time_delta) && next_event >= 0.0) {
505 time_delta = next_event;
509 XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", time_delta);
511 XBT_DEBUG("Looking for next trace event");
513 while (true) { // Handle next occurring events until none remains
514 double next_event_date = profile::future_evt_set.next_date();
515 XBT_DEBUG("Next TRACE event: %f", next_event_date);
517 for (auto* model : models_) {
518 /* Skip all idempotent models, they were already treated above
519 * NS3 is the one to handled here */
520 if (model->next_occurring_event_is_idempotent())
523 if (next_event_date != -1.0) {
524 time_delta = std::min(next_event_date - now_, time_delta);
526 time_delta = std::max(next_event_date - now_, time_delta); // Get the positive component
529 XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
530 // run until min or next flow
531 double model_next_action_end = model->next_occurring_event(time_delta);
533 XBT_DEBUG("Min for network : %f", model_next_action_end);
534 if (model_next_action_end >= 0.0)
535 time_delta = model_next_action_end;
538 if (next_event_date < 0.0 || (next_event_date > now_ + time_delta)) {
539 // next event may have already occurred or will after the next resource change, then bail out
540 XBT_DEBUG("no next usable TRACE event. Stop searching for it");
544 XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, now_, next_event_date);
546 while (auto* event = profile::future_evt_set.pop_leq(next_event_date, &value, &resource)) {
549 if (resource->is_used()) {
550 time_delta = next_event_date - now_;
551 XBT_DEBUG("This event invalidates the next_occurring_event() computation of models. Next event set to %f",
554 // FIXME: I'm too lame to update now_ live, so I change it and restore it so that the real update works
555 double round_start = now_;
556 now_ = next_event_date;
557 /* update state of the corresponding resource to the new value. Does not touch lmm.
558 It will be modified if needed when updating actions */
559 XBT_DEBUG("Calling update_resource_state for resource %s", resource->get_cname());
560 resource->apply_event(event, value);
565 /* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are
566 * with availability = 0. This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a
567 * trace with periodicity > 0.
568 * The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed
570 if (time_delta < 0) {
571 XBT_DEBUG("No next event at all. Bail out now.");
575 XBT_DEBUG("Duration set to %f", time_delta);
577 // Bump the time: jump into the future
580 // Inform the models of the date change
581 for (auto const& model : models_)
582 model->update_actions_state(now_, time_delta);
584 s4u::Engine::on_time_advance(time_delta);
589 void EngineImpl::run(double max_date)
593 XBT_DEBUG("Running the main loop until t=%.3f in mode %s", max_date,
594 to_c_str(simgrid::mc::get_model_checking_mode()));
596 if (MC_is_active()) {
598 mc::AppSide::get()->main_loop();
600 xbt_die("MC_is_active() is not supposed to return true in non-MC settings");
602 THROW_IMPOSSIBLE; // main_loop never returns
605 if (MC_record_replay_is_active()) {
606 mc::RecordTrace::replay(MC_record_path());
611 double elapsed_time = -1;
612 const std::set<s4u::Activity*>* vetoed_activities = s4u::Activity::get_vetoed_activities();
615 XBT_DEBUG("New Schedule Round; size(queue)=%zu", actors_to_run_.size());
617 if (cfg_breakpoint >= 0.0 && simgrid_get_clock() >= cfg_breakpoint) {
618 XBT_DEBUG("Breakpoint reached (%g)", cfg_breakpoint.get());
619 cfg_breakpoint = -1.0; // Let the simulation continue without hiting the breakpoint again and again
627 while (not actors_to_run_.empty()) {
628 XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", actors_to_run_.size());
630 /* Run all actors that are ready to run, possibly in parallel */
633 /* answer sequentially and in a fixed arbitrary order all the simcalls that were issued during that sub-round.
634 * The order must be fixed for the simulation to be reproducible (see RR-7653). It's OK here because only maestro
635 * changes the list. Killer actors are moved to the end to let victims finish their simcall before dying, but
636 * the order remains reproducible (even if arbitrarily). No need to sort the vector for sake of reproducibility.
638 for (auto const& actor : actors_that_ran_)
639 if (actor->simcall_.call_ != actor::Simcall::Type::NONE)
640 actor->simcall_handle(0);
642 handle_ended_actions();
644 /* If only daemon actors remain, cancel their actions, mark them to die and reschedule them */
645 if (actor_list_.size() == daemons_.size())
646 for (auto const& dmon : daemons_) {
647 XBT_DEBUG("Kill %s", dmon->get_cname());
648 maestro_->kill(dmon);
652 // Compute the max_date of the next solve.
653 // It's either when a timer occurs, or when user-specified deadline is reached, or -1 if none is given
654 double next_time = timer::Timer::next();
655 if (next_time < 0 && max_date > -1) {
656 next_time = max_date;
657 } else if (next_time > -1 && max_date > -1) { // either both <0, or both >0
658 next_time = std::min(next_time, max_date);
661 XBT_DEBUG("Calling solve(%g) %g", next_time, now_);
662 elapsed_time = solve(next_time);
663 XBT_DEBUG("Moving time ahead. NOW=%g; elapsed: %g", now_, elapsed_time);
665 // Execute timers until there isn't anything to be done:
668 again = timer::Timer::execute_all();
669 handle_ended_actions();
672 /* Clean actors to destroy */
675 XBT_DEBUG("### elapsed time %f, #actors %zu, #to_run %zu, #vetoed %d", elapsed_time, actor_list_.size(),
676 actors_to_run_.size(), (vetoed_activities == nullptr ? -1 : static_cast<int>(vetoed_activities->size())));
678 if (elapsed_time < 0. && actors_to_run_.empty() && not actor_list_.empty()) {
679 if (actor_list_.size() <= daemons_.size()) {
680 XBT_CRITICAL("Oops! Daemon actors cannot do any blocking activity (communications, synchronization, etc) "
681 "once the simulation is over. Please fix your on_exit() functions.");
683 XBT_CRITICAL("Oops! Deadlock detected, some activities are still around but will never complete. "
684 "This usually happens when the user code is not perfectly clean.");
686 display_all_actor_status();
687 simgrid::s4u::Engine::on_deadlock();
688 for (auto const& [_, actor] : actor_list_) {
689 XBT_DEBUG("Kill %s", actor->get_cname());
690 maestro_->kill(actor);
693 } while ((vetoed_activities == nullptr || vetoed_activities->empty()) &&
694 ((elapsed_time > -1.0 && not double_equals(max_date, now_, 0.00001)) || has_actors_to_run()));
696 if (not actor_list_.empty() && max_date < 0 && not(vetoed_activities == nullptr || vetoed_activities->empty()))
699 simgrid::s4u::Engine::on_simulation_end();
702 double EngineImpl::get_clock()
706 } // namespace simgrid::kernel