Logo AND Algorithmique Numérique Distribuée

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