Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move global variables to class Context.
[simgrid.git] / src / simix / smx_global.cpp
1 /* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "mc/mc.h"
7 #include "simgrid/s4u/Engine.hpp"
8 #include "simgrid/s4u/Host.hpp"
9 #include "src/smpi/include/smpi_actor.hpp"
10
11 #include "simgrid/sg_config.hpp"
12 #include "src/kernel/activity/ExecImpl.hpp"
13 #include "src/kernel/activity/IoImpl.hpp"
14 #include "src/kernel/activity/MailboxImpl.hpp"
15 #include "src/kernel/activity/SleepImpl.hpp"
16 #include "src/kernel/activity/SynchroRaw.hpp"
17 #include "src/mc/mc_record.hpp"
18 #include "src/mc/mc_replay.hpp"
19 #include "src/simix/smx_private.hpp"
20 #include "src/surf/StorageImpl.hpp"
21 #include "src/surf/xml/platf.hpp"
22
23 #if SIMGRID_HAVE_MC
24 #include "src/mc/remote/AppSide.hpp"
25 #endif
26
27 #include <memory>
28
29 XBT_LOG_NEW_CATEGORY(simix, "All SIMIX categories");
30 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)");
31
32 std::unique_ptr<simgrid::simix::Global> simix_global;
33
34 void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr;
35
36 namespace simgrid {
37 namespace simix {
38 config::Flag<bool> cfg_verbose_exit{"debug/verbose-exit", {"verbose-exit"}, "Display the actor status at exit", true};
39 } // namespace simix
40 } // namespace simgrid
41
42 XBT_ATTRIB_NORETURN static void inthandler(int)
43 {
44   if (simgrid::simix::cfg_verbose_exit) {
45     XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option "
46              "'debug/verbose-exit').");
47     simix_global->display_all_actor_status();
48   }
49   else {
50     XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false.");
51   }
52   exit(1);
53 }
54
55 #ifndef _WIN32
56 static void segvhandler(int signum, siginfo_t* siginfo, void* /*context*/)
57 {
58   if ((siginfo->si_signo == SIGSEGV && siginfo->si_code == SEGV_ACCERR) || siginfo->si_signo == SIGBUS) {
59     fprintf(stderr,
60             "Access violation or Bus error detected.\n"
61             "This probably comes from a programming error in your code, or from a stack\n"
62             "overflow. If you are certain of your code, try increasing the stack size\n"
63             "   --cfg=contexts/stack-size=XXX (current size is %u KiB).\n"
64             "\n"
65             "If it does not help, this may have one of the following causes:\n"
66             "a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n"
67             "Failing hardware can sometimes generate such errors too.\n"
68             "\n"
69             "If you think you've found a bug in SimGrid, please report it along with a\n"
70             "Minimal Working Example (MWE) reproducing your problem and a full backtrace\n"
71             "of the fault captured with gdb or valgrind.\n",
72             smx_context_stack_size / 1024);
73   } else  if (siginfo->si_signo == SIGSEGV) {
74     fprintf(stderr, "Segmentation fault.\n");
75 #if HAVE_SMPI
76     if (smpi_enabled() && smpi_cfg_privatization() == SmpiPrivStrategies::NONE) {
77 #if HAVE_PRIVATIZATION
78       fprintf(stderr, "Try to enable SMPI variable privatization with --cfg=smpi/privatization:yes.\n");
79 #else
80       fprintf(stderr, "Sadly, your system does not support --cfg=smpi/privatization:yes (yet).\n");
81 #endif /* HAVE_PRIVATIZATION */
82     }
83 #endif /* HAVE_SMPI */
84   }
85   std::raise(signum);
86 }
87
88 std::array<unsigned char, SIGSTKSZ> sigsegv_stack; /* alternate stack for SIGSEGV handler */
89
90 /**
91  * Install signal handler for SIGSEGV.  Check that nobody has already installed
92  * its own handler.  For example, the Java VM does this.
93  */
94 static void install_segvhandler()
95 {
96   stack_t old_stack;
97
98   if (simgrid::kernel::context::Context::install_sigsegv_stack(&old_stack, true) == -1) {
99     XBT_WARN("Failed to register alternate signal stack: %s", strerror(errno));
100     return;
101   }
102   if (not(old_stack.ss_flags & SS_DISABLE)) {
103     XBT_DEBUG("An alternate stack was already installed (sp=%p, size=%zu, flags=%x). Restore it.", old_stack.ss_sp,
104               old_stack.ss_size, (unsigned)old_stack.ss_flags);
105     sigaltstack(&old_stack, nullptr);
106   }
107
108   struct sigaction action;
109   struct sigaction old_action;
110   action.sa_sigaction = &segvhandler;
111   action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
112   sigemptyset(&action.sa_mask);
113
114   /* Linux tend to raise only SIGSEGV where other systems also raise SIGBUS on severe error */
115   for (int sig : {SIGSEGV, SIGBUS}) {
116     if (sigaction(sig, &action, &old_action) == -1) {
117       XBT_WARN("Failed to register signal handler for signal %d: %s", sig, strerror(errno));
118       continue;
119     }
120     if ((old_action.sa_flags & SA_SIGINFO) || old_action.sa_handler != SIG_DFL) {
121       XBT_DEBUG("A signal handler was already installed for signal %d (%p). Restore it.", sig,
122                 (old_action.sa_flags & SA_SIGINFO) ? (void*)old_action.sa_sigaction : (void*)old_action.sa_handler);
123       sigaction(sig, &old_action, nullptr);
124     }
125   }
126 }
127
128 #endif /* _WIN32 */
129
130 /********************************* SIMIX **************************************/
131 namespace simgrid {
132 namespace simix {
133
134 Timer* Timer::set(double date, xbt::Task<void()>&& callback)
135 {
136   auto* timer    = new Timer(date, std::move(callback));
137   timer->handle_ = simix_timers.emplace(std::make_pair(date, timer));
138   return timer;
139 }
140
141 /** @brief cancels a timer that was added earlier */
142 void Timer::remove()
143 {
144   simix_timers.erase(handle_);
145   delete this;
146 }
147
148 /** Execute all the tasks that are queued, e.g. `.then()` callbacks of futures. */
149 bool Global::execute_tasks()
150 {
151   xbt_assert(tasksTemp.empty());
152
153   if (tasks.empty())
154     return false;
155
156   do {
157     // We don't want the callbacks to modify the vector we are iterating over:
158     tasks.swap(tasksTemp);
159
160     // Execute all the queued tasks:
161     for (auto& task : tasksTemp)
162       task();
163
164     tasksTemp.clear();
165   } while (not tasks.empty());
166
167   return true;
168 }
169
170 void Global::empty_trash()
171 {
172   while (not actors_to_destroy.empty()) {
173     kernel::actor::ActorImpl* actor = &actors_to_destroy.front();
174     actors_to_destroy.pop_front();
175     XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
176     intrusive_ptr_release(actor);
177   }
178 #if SIMGRID_HAVE_MC
179   xbt_dynar_reset(dead_actors_vector);
180 #endif
181 }
182 /**
183  * @brief Executes the actors in actors_to_run.
184  *
185  * The actors in actors_to_run are run (in parallel if possible). On exit, actors_to_run is empty, and actors_that_ran
186  * contains the list of actors that just ran.  The two lists are swapped so, be careful when using them before and after
187  * a call to this function.
188  */
189 void Global::run_all_actors()
190 {
191   simix_global->context_factory->run_all();
192
193   actors_to_run.swap(actors_that_ran);
194   actors_to_run.clear();
195 }
196
197 /** Wake up all actors waiting for a Surf action to finish */
198 void Global::wake_all_waiting_actors() const
199 {
200   for (auto const& model : all_existing_models) {
201     kernel::resource::Action* action;
202
203     XBT_DEBUG("Handling the failed actions (if any)");
204     while ((action = model->extract_failed_action())) {
205       XBT_DEBUG("   Handling Action %p", action);
206       if (action->get_activity() != nullptr)
207         kernel::activity::ActivityImplPtr(action->get_activity())->post();
208     }
209     XBT_DEBUG("Handling the terminated actions (if any)");
210     while ((action = model->extract_done_action())) {
211       XBT_DEBUG("   Handling Action %p", action);
212       if (action->get_activity() == nullptr)
213         XBT_DEBUG("probably vcpu's action %p, skip", action);
214       else
215         kernel::activity::ActivityImplPtr(action->get_activity())->post();
216     }
217   }
218 }
219
220 void Global::display_all_actor_status() const
221 {
222   XBT_INFO("%zu actors are still running, waiting for something.", process_list.size());
223   /*  List the actors and their state */
224   XBT_INFO("Legend of the following listing: \"Actor <pid> (<name>@<host>): <status>\"");
225   for (auto const& kv : process_list) {
226     kernel::actor::ActorImpl* actor = kv.second;
227
228     if (actor->waiting_synchro_) {
229       const char* synchro_description = "unknown";
230
231       if (boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(actor->waiting_synchro_) != nullptr)
232         synchro_description = "execution";
233
234       if (boost::dynamic_pointer_cast<kernel::activity::CommImpl>(actor->waiting_synchro_) != nullptr)
235         synchro_description = "communication";
236
237       if (boost::dynamic_pointer_cast<kernel::activity::SleepImpl>(actor->waiting_synchro_) != nullptr)
238         synchro_description = "sleeping";
239
240       if (boost::dynamic_pointer_cast<kernel::activity::RawImpl>(actor->waiting_synchro_) != nullptr)
241         synchro_description = "synchronization";
242
243       if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro_) != nullptr)
244         synchro_description = "I/O";
245
246       XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %d to finish", actor->get_pid(),
247                actor->get_cname(), actor->get_host()->get_cname(), synchro_description,
248                (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()),
249                actor->waiting_synchro_->get_cname(), (int)actor->waiting_synchro_->state_);
250     } else {
251       XBT_INFO("Actor %ld (%s@%s)", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname());
252     }
253   }
254 }
255
256 config::Flag<double> cfg_breakpoint{
257     "debug/breakpoint", {"simix/breakpoint"}, "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
258 } // namespace simix
259 } // namespace simgrid
260
261 static simgrid::kernel::actor::ActorCode maestro_code;
262 void SIMIX_set_maestro(void (*code)(void*), void* data)
263 {
264 #ifdef _WIN32
265   XBT_INFO("WARNING, SIMIX_set_maestro is believed to not work on windows. Please help us investigating this issue if you need that feature");
266 #endif
267   maestro_code = std::bind(code, data);
268 }
269
270 /**
271  * @ingroup SIMIX_API
272  * @brief Initialize SIMIX internal data.
273  */
274 void SIMIX_global_init(int *argc, char **argv)
275 {
276 #if SIMGRID_HAVE_MC
277   // The communication initialization is done ASAP.
278   // We need to communicate  initialization of the different layers to the model-checker.
279   simgrid::mc::AppSide::initialize();
280 #endif
281
282   if (simix_global == nullptr) {
283     surf_init(argc, argv); /* Initialize SURF structures */
284
285     simix_global           = std::make_unique<simgrid::simix::Global>();
286     simix_global->maestro_ = nullptr;
287     SIMIX_context_mod_init();
288
289     // Either create a new context with maestro or create
290     // a context object with the current context maestro):
291     simgrid::kernel::actor::create_maestro(maestro_code);
292
293     /* Prepare to display some more info when dying on Ctrl-C pressing */
294     std::signal(SIGINT, inthandler);
295
296 #ifndef _WIN32
297     install_segvhandler();
298 #endif
299     /* register a function to be called by SURF after the environment creation */
300     sg_platf_init();
301     simgrid::s4u::Engine::on_platform_created.connect(surf_presolve);
302   }
303
304   if (simgrid::config::get_value<bool>("debug/clean-atexit"))
305     atexit(SIMIX_clean);
306 }
307
308 int smx_cleaned = 0;
309 /**
310  * @ingroup SIMIX_API
311  * @brief Clean the SIMIX simulation
312  *
313  * This functions remove the memory used by SIMIX
314  */
315 void SIMIX_clean()
316 {
317   if (smx_cleaned)
318     return; // to avoid double cleaning by java and C
319
320   smx_cleaned = 1;
321   XBT_DEBUG("SIMIX_clean called. Simulation's over.");
322   if (not simix_global->actors_to_run.empty() && SIMIX_get_clock() <= 0.0) {
323     XBT_CRITICAL("   ");
324     XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
325     XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
326     xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
327   }
328
329 #if HAVE_SMPI
330   if (not simix_global->process_list.empty()) {
331     if(smpi_process()->initialized()){
332       xbt_die("Process exited without calling MPI_Finalize - Killing simulation");
333     }else{
334       XBT_WARN("Process called exit when leaving - Skipping cleanups");
335       return;
336     }
337   }
338 #endif
339
340   /* Kill all processes (but maestro) */
341   simix_global->maestro_->kill_all();
342   simix_global->run_all_actors();
343   simix_global->empty_trash();
344
345   /* Exit the SIMIX network module */
346   SIMIX_mailbox_exit();
347
348   while (not simgrid::simix::simix_timers.empty()) {
349     delete simgrid::simix::simix_timers.top().second;
350     simgrid::simix::simix_timers.pop();
351   }
352   /* Free the remaining data structures */
353   simix_global->actors_to_run.clear();
354   simix_global->actors_that_ran.clear();
355   simix_global->actors_to_destroy.clear();
356   simix_global->process_list.clear();
357
358 #if SIMGRID_HAVE_MC
359   xbt_dynar_free(&simix_global->actors_vector);
360   xbt_dynar_free(&simix_global->dead_actors_vector);
361 #endif
362
363   /* Let's free maestro now */
364   delete simix_global->maestro_;
365   simix_global->maestro_ = nullptr;
366
367   /* Finish context module and SURF */
368   SIMIX_context_mod_exit();
369
370   surf_exit();
371
372   simix_global = nullptr;
373 }
374
375 /**
376  * @ingroup SIMIX_API
377  * @brief A clock (in second).
378  *
379  * @return Return the clock.
380  */
381 double SIMIX_get_clock()
382 {
383   if(MC_is_active() || MC_record_replay_is_active()){
384     return MC_process_clock_get(SIMIX_process_self());
385   }else{
386     return surf_get_clock();
387   }
388 }
389
390 /** Handle any pending timer. Returns if something was actually run. */
391 static bool SIMIX_execute_timers()
392 {
393   bool result = false;
394   while (not simgrid::simix::simix_timers.empty() && SIMIX_get_clock() >= simgrid::simix::simix_timers.top().first) {
395     result = true;
396     // FIXME: make the timers being real callbacks (i.e. provide dispatchers that read and expand the args)
397     smx_timer_t timer = simgrid::simix::simix_timers.top().second;
398     simgrid::simix::simix_timers.pop();
399     timer->callback();
400     delete timer;
401   }
402   return result;
403 }
404
405 /**
406  * @ingroup SIMIX_API
407  * @brief Run the main simulation loop.
408  */
409 void SIMIX_run()
410 {
411   if (MC_record_replay_is_active()) {
412     simgrid::mc::replay(MC_record_path);
413     return;
414   }
415
416   double time = 0;
417
418   do {
419     XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
420
421     if (simgrid::simix::cfg_breakpoint >= 0.0 && surf_get_clock() >= simgrid::simix::cfg_breakpoint) {
422       XBT_DEBUG("Breakpoint reached (%g)", simgrid::simix::cfg_breakpoint.get());
423       simgrid::simix::cfg_breakpoint = -1.0;
424 #ifdef SIGTRAP
425       std::raise(SIGTRAP);
426 #else
427       std::raise(SIGABRT);
428 #endif
429     }
430
431     simix_global->execute_tasks();
432
433     while (not simix_global->actors_to_run.empty()) {
434       XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
435
436       /* Run all processes that are ready to run, possibly in parallel */
437       simix_global->run_all_actors();
438
439       /* answer sequentially and in a fixed arbitrary order all the simcalls that were issued during that sub-round */
440
441       /* WARNING, the order *must* be fixed or you'll jeopardize the simulation reproducibility (see RR-7653) */
442
443       /* Here, the order is ok because:
444        *
445        *   Short proof: only maestro adds stuff to the actors_to_run array, so the execution order of user contexts do
446        *   not impact its order.
447        *
448        *   Long proof: actors remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
449        *
450        *   - if there is no kill during the simulation, actors remain sorted according by their PID.
451        *     Rationale: This can be proved inductively.
452        *        Assume that actors_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
453        *        is parsed linearly).
454        *        Let's show that it is still so at the end of this round.
455        *        - if an actor is added when being created, that's from maestro. It can be either at startup
456        *          time (and then in PID order), or in response to a process_create simcall. Since simcalls are handled
457        *          in arbitrary order (inductive hypothesis), we are fine.
458        *        - If an actor is added because it's getting killed, its subsequent actions shouldn't matter
459        *        - If an actor gets added to actors_to_run because one of their blocking action constituting the meat
460        *          of a simcall terminates, we're still good. Proof:
461        *          - You are added from ActorImpl::simcall_answer() only. When this function is called depends on the
462        *            resource kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications
463        *            as an example.
464        *          - For communications, this function is called from SIMIX_comm_finish().
465        *            This function itself don't mess with the order since simcalls are handled in FIFO order.
466        *            The function is called:
467        *            - before the comm starts (invalid parameters, or resource already dead or whatever).
468        *              The order then trivial holds since maestro didn't interrupt its handling of the simcall yet
469        *            - because the communication failed or were canceled after startup. In this case, it's called from
470        *              the function we are in, by the chunk:
471        *                       set = model->states.failed_action_set;
472        *                       while ((synchro = extract(set)))
473        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
474        *              This order is also fixed because it depends of the order in which the surf actions were
475        *              added to the system, and only maestro can add stuff this way, through simcalls.
476        *              We thus use the inductive hypothesis once again to conclude that the order in which synchros are
477        *              popped out of the set does not depend on the user code's execution order.
478        *            - because the communication terminated. In this case, synchros are served in the order given by
479        *                       set = model->states.done_action_set;
480        *                       while ((synchro = extract(set)))
481        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
482        *              and the argument is very similar to the previous one.
483        *            So, in any case, the orders of calls to CommImpl::finish() do not depend on the order in which user
484        *            actors are executed.
485        *          So, in any cases, the orders of actors within actors_to_run do not depend on the order in which
486        *          user actors were executed previously.
487        *     So, if there is no killing in the simulation, the simulation reproducibility is not jeopardized.
488        *   - If there is some actor killings, the order is changed by this decision that comes from user-land
489        *     But this decision may not have been motivated by a situation that were different because the simulation is
490        *     not reproducible.
491        *     So, even the order change induced by the actor killing is perfectly reproducible.
492        *
493        *   So science works, bitches [http://xkcd.com/54/].
494        *
495        *   We could sort the actors_that_ran array completely so that we can describe the order in which simcalls are
496        *   handled (like "according to the PID of issuer"), but it's not mandatory (order is fixed already even if
497        *   unfriendly).
498        *   That would thus be a pure waste of time.
499        */
500
501       for (auto const& actor : simix_global->actors_that_ran) {
502         if (actor->simcall_.call_ != SIMCALL_NONE) {
503           actor->simcall_handle(0);
504         }
505       }
506
507       simix_global->execute_tasks();
508       do {
509         simix_global->wake_all_waiting_actors();
510       } while (simix_global->execute_tasks());
511
512       /* If only daemon processes remain, cancel their actions, mark them to die and reschedule them */
513       if (simix_global->process_list.size() == simix_global->daemons.size())
514         for (auto const& dmon : simix_global->daemons) {
515           XBT_DEBUG("Kill %s", dmon->get_cname());
516           simix_global->maestro_->kill(dmon);
517         }
518     }
519
520     time = simgrid::simix::Timer::next();
521     if (time > -1.0 || not simix_global->process_list.empty()) {
522       XBT_DEBUG("Calling surf_solve");
523       time = surf_solve(time);
524       XBT_DEBUG("Moving time ahead : %g", time);
525     }
526
527     /* Notify all the hosts that have failed */
528     /* FIXME: iterate through the list of failed host and mark each of them */
529     /* as failed. On each host, signal all the running processes with host_fail */
530
531     // Execute timers and tasks until there isn't anything to be done:
532     bool again = false;
533     do {
534       again = SIMIX_execute_timers();
535       if (simix_global->execute_tasks())
536         again = true;
537       simix_global->wake_all_waiting_actors();
538     } while (again);
539
540     /* Clean actors to destroy */
541     simix_global->empty_trash();
542
543     XBT_DEBUG("### time %f, #processes %zu, #to_run %zu", time, simix_global->process_list.size(),
544               simix_global->actors_to_run.size());
545
546     if (time < 0. && simix_global->actors_to_run.empty() && not simix_global->process_list.empty()) {
547       if (simix_global->process_list.size() <= simix_global->daemons.size()) {
548         XBT_CRITICAL("Oops! Daemon actors cannot do any blocking activity (communications, synchronization, etc) "
549                      "once the simulation is over. Please fix your on_exit() functions.");
550       } else {
551         XBT_CRITICAL("Oops! Deadlock or code not perfectly clean.");
552       }
553       simix_global->display_all_actor_status();
554       simgrid::s4u::Engine::on_deadlock();
555       for (auto const& kv : simix_global->process_list) {
556         XBT_DEBUG("Kill %s", kv.second->get_cname());
557         simix_global->maestro_->kill(kv.second);
558       }
559     }
560   } while (time > -1.0 || not simix_global->actors_to_run.empty());
561
562   if (not simix_global->process_list.empty())
563     THROW_IMPOSSIBLE;
564
565   simgrid::s4u::Engine::on_simulation_end();
566 }
567
568 double SIMIX_timer_next() // XBT_ATTRIB_DEPRECATED_v329
569 {
570   return simgrid::simix::Timer::next();
571 }
572
573 smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void* arg) // XBT_ATTRIB_DEPRECATED_v329
574 {
575   return simgrid::simix::Timer::set(date, std::bind(callback, arg));
576 }
577
578 /** @brief cancels a timer that was added earlier */
579 void SIMIX_timer_remove(smx_timer_t timer) // XBT_ATTRIB_DEPRECATED_v329
580 {
581   timer->remove();
582 }
583
584 /** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */
585 double SIMIX_timer_get_date(smx_timer_t timer) // XBT_ATTRIB_DEPRECATED_v329
586 {
587   return timer ? timer->get_date() : 0;
588 }
589
590 void SIMIX_display_process_status() // XBT_ATTRIB_DEPRECATED_v329
591 {
592   simix_global->display_all_actor_status();
593 }
594
595 int SIMIX_is_maestro()
596 {
597   if (simix_global == nullptr) // SimDag
598     return true;
599   const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
600   return self == nullptr || self == simix_global->maestro_;
601 }