-/**
- * @brief Internal function to kill a SIMIX process.
- *
- * This function may be called when a SIMCALL_PROCESS_KILL simcall occurs,
- * or directly for SIMIX internal purposes.
- *
- * @param actor poor victim
- * @param issuer the actor which has sent the PROCESS_KILL. Important to not schedule twice the same actor.
- */
-void SIMIX_process_kill(smx_actor_t actor, smx_actor_t issuer)
-{
-
- if (actor->finished_) {
- XBT_DEBUG("Ignoring request to kill process %s@%s that is already dead", actor->get_cname(),
- actor->host_->get_cname());
- return;
- }
-
- XBT_DEBUG("Actor '%s'@%s is killing actor '%s'@%s", issuer == nullptr ? "(null)" : issuer->get_cname(),
- (issuer == nullptr || issuer->host_ == nullptr ? "(null)" : issuer->host_->get_cname()), actor->get_cname(),
- actor->host_->get_cname());
-
- actor->context_->iwannadie = true;
- actor->blocked_ = false;
- actor->suspended_ = false;
- actor->exception = nullptr;
-
- // Forcefully kill the actor if its host is turned off. Not an HostFailureException because you should not survive that
- if (actor->host_->is_off())
- actor->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
-
- /* destroy the blocking synchro if any */
- if (actor->waiting_synchro != nullptr) {
-
- simgrid::kernel::activity::ExecImplPtr exec =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(actor->waiting_synchro);
- simgrid::kernel::activity::CommImplPtr comm =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(actor->waiting_synchro);
- simgrid::kernel::activity::SleepImplPtr sleep =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro);
- simgrid::kernel::activity::RawImplPtr raw =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(actor->waiting_synchro);
- simgrid::kernel::activity::IoImplPtr io =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(actor->waiting_synchro);
-
- if (exec != nullptr) {
- if (exec->surf_action_) {
- exec->surf_action_->cancel();
- exec->surf_action_->unref();
- exec->surf_action_ = nullptr;
- }
- } else if (comm != nullptr) {
- actor->comms.remove(actor->waiting_synchro);
- comm->cancel();
- // Remove first occurrence of &process->simcall:
- auto i = boost::range::find(actor->waiting_synchro->simcalls_, &actor->simcall);
- if (i != actor->waiting_synchro->simcalls_.end())
- actor->waiting_synchro->simcalls_.remove(&actor->simcall);
- } else if (sleep != nullptr) {
- if (sleep->surf_action_)
- sleep->surf_action_->cancel();
- sleep->post();
- } else if (raw != nullptr) {
- SIMIX_synchro_stop_waiting(actor, &actor->simcall);
-
- } else if (io != nullptr) {
- delete io.get();
- } else {
- simgrid::kernel::activity::ActivityImplPtr activity = actor->waiting_synchro;
- xbt_die("Activity %s is of unknown type %s", activity->name_.c_str(),
- simgrid::xbt::demangle(typeid(activity).name()).get());
- }
-
- actor->waiting_synchro = nullptr;
- }
- if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), actor) ==
- end(simix_global->process_to_run) &&
- actor != issuer) {
- XBT_DEBUG("Inserting %s in the to_run list", actor->get_cname());
- simix_global->process_to_run.push_back(actor);
- }
-}
-