1 /* Copyright (c) 2007-2019. 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. */
7 #include "simgrid/Exception.hpp"
8 #include "smx_private.hpp"
9 #include "src/kernel/activity/CommImpl.hpp"
10 #include "src/kernel/activity/ExecImpl.hpp"
11 #include "src/kernel/activity/IoImpl.hpp"
12 #include "src/kernel/activity/SleepImpl.hpp"
13 #include "src/kernel/activity/SynchroRaw.hpp"
14 #include "src/mc/mc_replay.hpp"
15 #include "src/mc/remote/Client.hpp"
16 #include "src/simix/smx_host_private.hpp"
17 #include "src/simix/smx_io_private.hpp"
18 #include "src/simix/smx_synchro_private.hpp"
19 #include "src/surf/HostImpl.hpp"
20 #include "src/surf/cpu_interface.hpp"
22 #include <boost/range/algorithm.hpp>
24 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, "Logging specific to SIMIX (process)");
26 static unsigned long simix_process_maxpid = 0;
29 * @brief Returns the current agent.
31 * This functions returns the currently running SIMIX process.
33 * @return The SIMIX process
35 smx_actor_t SIMIX_process_self()
37 smx_context_t self_context = simgrid::kernel::context::Context::self();
39 return (self_context != nullptr) ? self_context->get_actor() : nullptr;
43 * @brief Returns whether a process has pending asynchronous communications.
44 * @return true if there are asynchronous communications in this process
46 int SIMIX_process_has_pending_comms(smx_actor_t process) {
48 return process->comms.size() > 0;
52 * @brief Moves a process to the list of processes to destroy.
54 void SIMIX_process_cleanup(smx_actor_t process)
56 XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", process->get_cname(), process,
57 process->waiting_synchro.get());
59 /* Unregister from the kill timer if any */
60 if (process->kill_timer != nullptr) {
61 SIMIX_timer_remove(process->kill_timer);
62 process->kill_timer = nullptr;
65 simix_global->mutex.lock();
67 simix_global->process_list.erase(process->pid_);
68 if (process->host_ && process->host_process_list_hook.is_linked())
69 simgrid::xbt::intrusive_erase(process->host_->pimpl_->process_list_, *process);
70 if (not process->smx_destroy_list_hook.is_linked()) {
72 xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process);
74 simix_global->process_to_destroy.push_back(*process);
76 process->context_->iwannadie = false;
78 simix_global->mutex.unlock();
84 * Should be called some time to time to free the memory allocated for processes that have finished (or killed).
86 void SIMIX_process_empty_trash()
88 while (not simix_global->process_to_destroy.empty()) {
89 smx_actor_t process = &simix_global->process_to_destroy.front();
90 simix_global->process_to_destroy.pop_front();
91 XBT_DEBUG("Getting rid of %p",process);
92 intrusive_ptr_release(process);
95 xbt_dynar_reset(simix_global->dead_actors_vector);
103 ActorImpl::ActorImpl(simgrid::xbt::string name, simgrid::s4u::Host* host) : name_(name), host_(host), piface_(this)
105 pid_ = simix_process_maxpid++;
106 simcall.issuer = this;
109 ActorImpl::~ActorImpl()
111 delete this->context_;
114 static void dying_daemon(int /*exit_status*/, void* data)
116 std::vector<ActorImpl*>* vect = &simix_global->daemons;
118 auto it = std::find(vect->begin(), vect->end(), static_cast<ActorImpl*>(data));
119 xbt_assert(it != vect->end(), "The dying daemon is not a daemon after all. Please report that bug.");
121 /* Don't move the whole content since we don't really care about the order */
122 std::swap(*it, vect->back());
126 /** This process will be terminated automatically when the last non-daemon process finishes */
127 void ActorImpl::daemonize()
131 simix_global->daemons.push_back(this);
132 SIMIX_process_on_exit(this, dying_daemon, this);
136 simgrid::s4u::Actor* ActorImpl::restart()
138 XBT_DEBUG("Restarting process %s on %s", get_cname(), host_->get_cname());
140 // retrieve the arguments of the old process
141 simgrid::kernel::actor::ProcessArg arg = ProcessArg(host_, this);
143 // kill the old process
144 SIMIX_process_kill(this, (this == simix_global->maestro_process) ? this : SIMIX_process_self());
146 // start the new process
148 SIMIX_process_create(arg.name, std::move(arg.code), arg.data, arg.host, arg.properties.get(), nullptr);
149 simcall_process_set_kill_time(actor, arg.kill_time);
150 actor->set_auto_restart(arg.auto_restart);
152 return actor->ciface();
155 smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
158 XBT_DEBUG("Actor '%s' is already suspended", get_cname());
164 /* If we are suspending another actor that is waiting on a sync, suspend its synchronization. */
165 if (this != issuer) {
167 waiting_synchro->suspend();
168 /* If the other actor is not waiting, its suspension is delayed to when the actor is rescheduled. */
172 return SIMIX_execution_start("suspend", "", 0.0, 1.0, 0.0, this->host_);
176 void ActorImpl::resume()
178 XBT_IN("process = %p", this);
180 if (context_->iwannadie) {
181 XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
189 /* resume the synchronization that was blocking the resumed actor. */
191 waiting_synchro->resume();
196 smx_activity_t ActorImpl::sleep(double duration)
199 throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
200 XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
202 simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
203 synchro->host = host_;
204 synchro->surf_sleep = host_->pimpl_cpu->sleep(duration);
205 synchro->surf_sleep->set_data(synchro);
206 XBT_DEBUG("Create sleep synchronization %p", synchro);
211 void ActorImpl::throw_exception(std::exception_ptr e)
218 /* cancel the blocking synchro if any */
219 if (waiting_synchro) {
221 simgrid::kernel::activity::ExecImplPtr exec =
222 boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(waiting_synchro);
223 if (exec != nullptr && exec->surf_action_)
224 exec->surf_action_->cancel();
226 simgrid::kernel::activity::CommImplPtr comm =
227 boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(waiting_synchro);
228 if (comm != nullptr) {
233 simgrid::kernel::activity::SleepImplPtr sleep =
234 boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(waiting_synchro);
235 if (sleep != nullptr) {
236 SIMIX_process_sleep_destroy(waiting_synchro);
237 if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), this) ==
238 end(simix_global->process_to_run) &&
239 this != SIMIX_process_self()) {
240 XBT_DEBUG("Inserting %s in the to_run list", get_cname());
241 simix_global->process_to_run.push_back(this);
245 simgrid::kernel::activity::RawImplPtr raw =
246 boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(waiting_synchro);
247 if (raw != nullptr) {
248 SIMIX_synchro_stop_waiting(this, &simcall);
251 simgrid::kernel::activity::IoImplPtr io =
252 boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(waiting_synchro);
257 waiting_synchro = nullptr;
260 void create_maestro(simgrid::simix::ActorCode code)
262 /* Create maestro process and initialize it */
263 smx_actor_t maestro = new simgrid::kernel::actor::ActorImpl(simgrid::xbt::string(""), /*host*/ nullptr);
266 maestro->context_ = SIMIX_context_new(simgrid::simix::ActorCode(), nullptr, maestro);
268 maestro->context_ = simix_global->context_factory->create_maestro(code, maestro);
271 maestro->simcall.issuer = maestro;
272 simix_global->maestro_process = maestro;
280 * @brief Internal function to create a process.
282 * This function actually creates the process.
283 * It may be called when a SIMCALL_PROCESS_CREATE simcall occurs,
284 * or directly for SIMIX internal purposes. The sure thing is that it's called from maestro context.
286 * @return the process created
288 smx_actor_t SIMIX_process_create(std::string name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
289 std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_process)
292 XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
294 if (host->is_off()) {
295 XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
299 smx_actor_t process = new simgrid::kernel::actor::ActorImpl(simgrid::xbt::string(name), host);
301 xbt_assert(code && host != nullptr, "Invalid parameters");
303 process->set_user_data(data);
304 process->code = code;
306 if (parent_process != nullptr)
307 process->ppid_ = parent_process->pid_;
309 XBT_VERB("Create context %s", process->get_cname());
310 process->context_ = SIMIX_context_new(std::move(code), &SIMIX_process_cleanup, process);
313 if (properties != nullptr)
314 for (auto const& kv : *properties)
315 process->set_property(kv.first, kv.second);
317 /* Add the process to its host's process list */
318 host->pimpl_->process_list_.push_back(*process);
320 XBT_DEBUG("Start context '%s'", process->get_cname());
322 /* Now insert it in the global process list and in the process to run list */
323 simix_global->process_list[process->pid_] = process;
324 XBT_DEBUG("Inserting %s(%s) in the to_run list", process->get_cname(), host->get_cname());
325 simix_global->process_to_run.push_back(process);
326 intrusive_ptr_add_ref(process);
328 /* The on_creation() signal must be delayed until there, where the pid and everything is set */
329 simgrid::s4u::Actor::on_creation(process->iface());
334 smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostname,
335 std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_process)
337 // This is mostly a copy/paste from SIMIX_process_new(),
338 // it'd be nice to share some code between those two functions.
340 sg_host_t host = sg_host_by_name(hostname);
341 XBT_DEBUG("Attach process %s on host '%s'", name, hostname);
343 if (host->is_off()) {
344 XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname);
348 smx_actor_t actor = new simgrid::kernel::actor::ActorImpl(simgrid::xbt::string(name), host);
350 actor->set_user_data(data);
351 actor->code = nullptr;
353 if (parent_process != nullptr)
354 actor->ppid_ = parent_process->pid_;
356 XBT_VERB("Create context %s", actor->get_cname());
357 xbt_assert(simix_global != nullptr, "simix is not initialized, please call MSG_init first");
358 actor->context_ = simix_global->context_factory->attach(&SIMIX_process_cleanup, actor);
361 if (properties != nullptr)
362 for (auto const& kv : *properties)
363 actor->set_property(kv.first, kv.second);
365 /* Add the process to it's host process list */
366 host->pimpl_->process_list_.push_back(*actor);
368 /* Now insert it in the global process list and in the process to run list */
369 simix_global->process_list[actor->pid_] = actor;
370 XBT_DEBUG("Inserting %s(%s) in the to_run list", actor->get_cname(), host->get_cname());
371 simix_global->process_to_run.push_back(actor);
372 intrusive_ptr_add_ref(actor);
374 auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(actor->context_);
375 xbt_assert(nullptr != context, "Not a suitable context");
376 context->attach_start();
378 /* The on_creation() signal must be delayed until there, where the pid and everything is set */
379 simgrid::s4u::ActorPtr tmp = actor->iface(); // Passing this directly to on_creation will lead to crashes
380 simgrid::s4u::Actor::on_creation(tmp);
385 void SIMIX_process_detach()
387 auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(simgrid::kernel::context::Context::self());
388 if (context == nullptr)
389 xbt_die("Not a suitable context");
391 SIMIX_process_cleanup(context->get_actor());
392 context->attach_stop();
396 * @brief Executes the processes from simix_global->process_to_run.
398 * The processes of simix_global->process_to_run are run (in parallel if
399 * possible). On exit, simix_global->process_to_run is empty, and
400 * simix_global->process_that_ran contains the list of processes that just ran.
401 * The two lists are swapped so, be careful when using them before and after a
402 * call to this function.
404 void SIMIX_process_runall()
406 SIMIX_context_runall();
408 simix_global->process_to_run.swap(simix_global->process_that_ran);
409 simix_global->process_to_run.clear();
413 * @brief Internal function to kill a SIMIX process.
415 * This function may be called when a SIMCALL_PROCESS_KILL simcall occurs,
416 * or directly for SIMIX internal purposes.
418 * @param actor poor victim
419 * @param issuer the actor which has sent the PROCESS_KILL. Important to not schedule twice the same actor.
421 void SIMIX_process_kill(smx_actor_t actor, smx_actor_t issuer)
424 if (actor->finished_) {
425 XBT_DEBUG("Ignoring request to kill process %s@%s that is already dead", actor->get_cname(),
426 actor->host_->get_cname());
430 XBT_DEBUG("Actor '%s'@%s is killing actor '%s'@%s", issuer == nullptr ? "(null)" : issuer->get_cname(),
431 (issuer == nullptr || issuer->host_ == nullptr ? "(null)" : issuer->host_->get_cname()), actor->get_cname(),
432 actor->host_->get_cname());
434 actor->context_->iwannadie = true;
435 actor->blocked_ = false;
436 actor->suspended_ = false;
437 actor->exception = nullptr;
439 // Forcefully kill the actor if its host is turned off. Not an HostFailureException because you should not survive that
440 if (actor->host_->is_off())
441 actor->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
443 /* destroy the blocking synchro if any */
444 if (actor->waiting_synchro != nullptr) {
446 simgrid::kernel::activity::ExecImplPtr exec =
447 boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(actor->waiting_synchro);
448 simgrid::kernel::activity::CommImplPtr comm =
449 boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(actor->waiting_synchro);
450 simgrid::kernel::activity::SleepImplPtr sleep =
451 boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro);
452 simgrid::kernel::activity::RawImplPtr raw =
453 boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(actor->waiting_synchro);
454 simgrid::kernel::activity::IoImplPtr io =
455 boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(actor->waiting_synchro);
457 if (exec != nullptr) {
458 if (exec->surf_action_) {
459 exec->surf_action_->cancel();
460 exec->surf_action_->unref();
461 exec->surf_action_ = nullptr;
463 } else if (comm != nullptr) {
464 actor->comms.remove(actor->waiting_synchro);
466 // Remove first occurrence of &process->simcall:
467 auto i = boost::range::find(actor->waiting_synchro->simcalls_, &actor->simcall);
468 if (i != actor->waiting_synchro->simcalls_.end())
469 actor->waiting_synchro->simcalls_.remove(&actor->simcall);
470 } else if (sleep != nullptr) {
471 if (sleep->surf_sleep)
472 sleep->surf_sleep->cancel();
474 } else if (raw != nullptr) {
475 SIMIX_synchro_stop_waiting(actor, &actor->simcall);
477 } else if (io != nullptr) {
480 simgrid::kernel::activity::ActivityImplPtr activity = actor->waiting_synchro;
481 xbt_die("Activity %s is of unknown type %s", activity->name_.c_str(),
482 simgrid::xbt::demangle(typeid(activity).name()).get());
485 actor->waiting_synchro = nullptr;
487 if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), actor) ==
488 end(simix_global->process_to_run) &&
490 XBT_DEBUG("Inserting %s in the to_run list", actor->get_cname());
491 simix_global->process_to_run.push_back(actor);
495 /** @deprecated When this function gets removed, also remove the xbt_ex class, that is only there to help users to
497 void SIMIX_process_throw(smx_actor_t actor, xbt_errcat_t cat, int value, const char* msg)
499 SMX_EXCEPTION(actor, cat, value, msg);
501 if (actor->suspended_)
504 /* cancel the blocking synchro if any */
505 if (actor->waiting_synchro) {
507 simgrid::kernel::activity::ExecImplPtr exec =
508 boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(actor->waiting_synchro);
509 if (exec != nullptr && exec->surf_action_)
510 exec->surf_action_->cancel();
512 simgrid::kernel::activity::CommImplPtr comm =
513 boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(actor->waiting_synchro);
514 if (comm != nullptr) {
515 actor->comms.remove(comm);
519 simgrid::kernel::activity::SleepImplPtr sleep =
520 boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro);
521 if (sleep != nullptr) {
522 SIMIX_process_sleep_destroy(actor->waiting_synchro);
523 if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), actor) ==
524 end(simix_global->process_to_run) &&
525 actor != SIMIX_process_self()) {
526 XBT_DEBUG("Inserting %s in the to_run list", actor->get_cname());
527 simix_global->process_to_run.push_back(actor);
531 simgrid::kernel::activity::RawImplPtr raw =
532 boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(actor->waiting_synchro);
533 if (raw != nullptr) {
534 SIMIX_synchro_stop_waiting(actor, &actor->simcall);
537 simgrid::kernel::activity::IoImplPtr io =
538 boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(actor->waiting_synchro);
543 actor->waiting_synchro = nullptr;
547 * @brief Kills all running processes.
548 * @param issuer this one will not be killed
550 void SIMIX_process_killall(smx_actor_t issuer)
552 for (auto const& kv : simix_global->process_list)
553 if (kv.second != issuer)
554 SIMIX_process_kill(kv.second, issuer);
557 void SIMIX_process_change_host(smx_actor_t actor, sg_host_t dest)
559 xbt_assert((actor != nullptr), "Invalid parameters");
560 simgrid::xbt::intrusive_erase(actor->host_->pimpl_->process_list_, *actor);
562 dest->pimpl_->process_list_.push_back(*actor);
565 void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t actor)
567 smx_activity_t sync_suspend = actor->suspend(simcall->issuer);
569 if (actor != simcall->issuer) {
570 SIMIX_simcall_answer(simcall);
572 sync_suspend->simcalls_.push_back(simcall);
573 actor->waiting_synchro = sync_suspend;
574 actor->waiting_synchro->suspend();
576 /* If we are suspending ourselves, then just do not finish the simcall now */
579 int SIMIX_process_get_maxpid() {
580 return simix_process_maxpid;
583 int SIMIX_process_count()
585 return simix_global->process_list.size();
588 void* SIMIX_process_self_get_data()
590 smx_actor_t self = SIMIX_process_self();
592 if (self == nullptr) {
595 return self->get_user_data();
598 void SIMIX_process_self_set_data(void *data)
600 SIMIX_process_self()->set_user_data(data);
604 /* needs to be public and without simcall because it is called
605 by exceptions and logging events */
606 const char* SIMIX_process_self_get_name() {
608 smx_actor_t process = SIMIX_process_self();
609 if (process == nullptr || process == simix_global->maestro_process)
612 return process->get_cname();
615 void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout)
617 if (process->finished_) {
618 // The joined process is already finished, just wake up the issuer process right away
619 simcall_process_sleep__set__result(simcall, SIMIX_DONE);
620 SIMIX_simcall_answer(simcall);
623 smx_activity_t sync = SIMIX_process_join(simcall->issuer, process, timeout);
624 sync->simcalls_.push_back(simcall);
625 simcall->issuer->waiting_synchro = sync;
628 smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, double timeout)
630 smx_activity_t res = issuer->sleep(timeout);
631 intrusive_ptr_add_ref(res.get());
632 SIMIX_process_on_exit(process,
634 auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(arg);
635 if (sleep->surf_sleep)
636 sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::FINISHED);
637 intrusive_ptr_release(sleep);
643 void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration)
645 if (MC_is_active() || MC_record_replay_is_active()) {
646 MC_process_clock_add(simcall->issuer, duration);
647 simcall_process_sleep__set__result(simcall, SIMIX_DONE);
648 SIMIX_simcall_answer(simcall);
651 smx_activity_t sync = simcall->issuer->sleep(duration);
652 sync->simcalls_.push_back(simcall);
653 simcall->issuer->waiting_synchro = sync;
656 void SIMIX_process_sleep_destroy(smx_activity_t synchro)
658 XBT_DEBUG("Destroy sleep synchro %p", synchro.get());
659 simgrid::kernel::activity::SleepImplPtr sleep =
660 boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(synchro);
662 if (sleep->surf_sleep) {
663 sleep->surf_sleep->unref();
664 sleep->surf_sleep = nullptr;
669 * @brief Calling this function makes the process to yield.
671 * Only the current process can call this function, giving back the control to maestro.
673 * @param self the current process
675 void SIMIX_process_yield(smx_actor_t self)
677 XBT_DEBUG("Yield actor '%s'", self->get_cname());
679 /* Go into sleep and return control to maestro */
680 self->context_->suspend();
682 /* Ok, maestro returned control to us */
683 XBT_DEBUG("Control returned to me: '%s'", self->get_cname());
685 if (self->context_->iwannadie) {
687 XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host_->get_cname());
688 // throw simgrid::kernel::context::StopRequest(); Does not seem to properly kill the actor
689 self->context_->stop();
693 if (self->suspended_) {
694 XBT_DEBUG("Hey! I'm suspended.");
695 xbt_assert(self->exception != nullptr, "Gasp! This exception may be lost by subsequent calls.");
696 self->suspended_ = false;
700 if (self->exception != nullptr) {
701 XBT_DEBUG("Wait, maestro left me an exception");
702 std::exception_ptr exception = std::move(self->exception);
703 self->exception = nullptr;
704 std::rethrow_exception(std::move(exception));
707 if (SMPI_switch_data_segment && not self->finished_) {
708 SMPI_switch_data_segment(self->iface());
712 /** @brief Returns the list of processes to run. */
713 const std::vector<smx_actor_t>& simgrid::simix::process_get_runnable()
715 return simix_global->process_to_run;
718 /** @brief Returns the process from PID. */
719 smx_actor_t SIMIX_process_from_PID(aid_t PID)
721 auto actor = simix_global->process_list.find(PID);
722 return actor == simix_global->process_list.end() ? nullptr : actor->second;
725 void SIMIX_process_on_exit(smx_actor_t actor, int_f_pvoid_pvoid_t fun, void* data)
727 SIMIX_process_on_exit(actor, [fun](int a, void* b) { fun((void*)(intptr_t)a, b); }, data);
730 void SIMIX_process_on_exit(smx_actor_t actor, std::function<void(int, void*)> fun, void* data)
732 xbt_assert(actor, "current process not found: are you in maestro context ?");
734 actor->on_exit.emplace_back(s_smx_process_exit_fun_t{fun, data});
737 /** @brief Restart a process, starting it again from the beginning. */
739 * @ingroup simix_process_management
740 * @brief Creates and runs a new SIMIX process.
742 * The structure and the corresponding thread are created and put in the list of ready processes.
744 * @param name a name for the process. It is for user-level information and can be nullptr.
745 * @param code the main function of the process
746 * @param data a pointer to any data one may want to attach to the new object. It is for user-level information and can
748 * It can be retrieved with the method ActorImpl::getUserData().
749 * @param host where the new agent is executed.
750 * @param properties the properties of the process
752 smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
753 std::unordered_map<std::string, std::string>* properties)
755 smx_actor_t self = SIMIX_process_self();
756 return simgrid::simix::simcall([name, code, data, host, properties, self] {
757 return SIMIX_process_create(name, std::move(code), data, host, properties, self);