- smx_host_priv_t host = sg_host_simix(h);
-
- xbt_assert((host != nullptr), "Invalid parameters");
-
- if (h->isOn()) {
- h->pimpl_cpu->turnOff();
-
- /* Clean Simulator data */
- if (xbt_swag_size(host->process_list) != 0) {
- smx_actor_t process = nullptr;
- xbt_swag_foreach(process, host->process_list) {
- SIMIX_process_kill(process, issuer);
- XBT_DEBUG("Killing %s on %s by %s",
- process->name.c_str(), sg_host_get_name(process->host),
- issuer->name.c_str());
- }
- }
- } else {
- XBT_INFO("Host %s is already off", h->name().c_str());
- }
-}
-
-sg_host_t SIMIX_host_self()
-{
- smx_actor_t process = SIMIX_process_self();
- return (process == nullptr) ? nullptr : process->host;
-}
-
-/* needs to be public and without simcall for exceptions and logging events */
-const char* SIMIX_host_self_get_name()
-{
- sg_host_t host = SIMIX_host_self();
- if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
- return "";
-
- return sg_host_get_name(host);
-}
-
-void _SIMIX_host_free_process_arg(void *data)
-{
- smx_process_arg_t arg = *(static_cast<smx_process_arg_t*>(data));
- delete arg;
-}
-/**
- * \brief Add a process to the list of the processes that the host will restart when it comes back
- * This function add a process to the list of the processes that will be restarted when the host comes
- * back. It is expected that this function is called when the host is down.
- * The processes will only be restarted once, meaning that you will have to register the process
- * again to restart the process again.
- */
-void SIMIX_host_add_auto_restart_process(
- sg_host_t host, const char *name, std::function<void()> code,
- void* data, double kill_time, xbt_dict_t properties, int auto_restart)
-{
- smx_process_arg_t arg = new simgrid::simix::ProcessArg();
- arg->name = name;
- arg->code = std::move(code);
- arg->data = data;
- arg->host = host;
- arg->kill_time = kill_time;
- arg->properties = properties;
- arg->auto_restart = auto_restart;
-
- if( host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_get_name(host))){
- xbt_dict_set(watched_hosts_lib,sg_host_get_name(host),host,nullptr);
- XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_get_name(host));
- }
- sg_host_simix(host)->auto_restart_processes.push_back(arg);
-}
-/** @brief Restart the list of processes that have been registered to the host */
-void SIMIX_host_autorestart(sg_host_t host)
-{
- std::vector<simgrid::simix::ProcessArg*> process_list = sg_host_simix(host)->auto_restart_processes;
- if (process_list.empty())
- return;
-
- for (auto arg : process_list) {
-
- XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->name().c_str());
- simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host, arg->kill_time,
- arg->properties, arg->auto_restart, nullptr);
- }
- process_list.clear();
-}
-
-smx_activity_t simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount,
- double priority, double bound) {
- return SIMIX_execution_start(simcall->issuer, name,flops_amount,priority,bound);
-}
-
-smx_activity_t SIMIX_execution_start(smx_actor_t issuer, const char *name, double flops_amount, double priority,
- double bound){
-
- /* alloc structures and initialize */
- simgrid::kernel::activity::Exec *exec = new simgrid::kernel::activity::Exec(name, issuer->host);
-
- /* set surf's action */
- if (!MC_is_active() && !MC_record_replay_is_active()) {
-
- exec->surf_exec = issuer->host->pimpl_cpu->execution_start(flops_amount);
- exec->surf_exec->setData(exec);
- exec->surf_exec->setPriority(priority);
-
- if (bound > 0)
- static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
- }
-
- XBT_DEBUG("Create execute synchro %p: %s", exec, exec->name.c_str());
-
- return exec;
-}
-
-smx_activity_t SIMIX_execution_parallel_start(const char *name, int host_nb, sg_host_t *host_list, double *flops_amount,
- double *bytes_amount, double amount, double rate){
-
- /* alloc structures and initialize */
- simgrid::kernel::activity::Exec *exec = new simgrid::kernel::activity::Exec(name, nullptr);