1 /* Copyright (c) 2007-2017. 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. */
6 #include "simgrid/s4u/Host.hpp"
8 #include "simgrid/kernel/resource/Action.hpp"
9 #include "src/kernel/activity/SleepImpl.hpp"
10 #include "src/kernel/context/Context.hpp"
12 #include "src/simix/ActorImpl.hpp"
13 #include "src/simix/popping_private.hpp"
14 #include "src/surf/surf_interface.hpp"
16 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
18 void simgrid::kernel::activity::SleepImpl::suspend()
20 surf_sleep->suspend();
23 void simgrid::kernel::activity::SleepImpl::resume()
28 void simgrid::kernel::activity::SleepImpl::post()
30 while (not simcalls.empty()) {
31 smx_simcall_t simcall = simcalls.front();
35 switch (surf_sleep->getState()) {
36 case simgrid::kernel::resource::Action::State::failed:
37 simcall->issuer->context->iwannadie = 1;
38 result = SIMIX_SRC_HOST_FAILURE;
41 case simgrid::kernel::resource::Action::State::done:
49 if (simcall->issuer->host->isOff()) {
50 simcall->issuer->context->iwannadie = 1;
52 simcall_process_sleep__set__result(simcall, result);
53 simcall->issuer->waiting_synchro = nullptr;
54 if (simcall->issuer->suspended) {
55 XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
56 simcall->issuer->suspended = 0;
57 simcall_HANDLER_process_suspend(simcall, simcall->issuer);
59 SIMIX_simcall_answer(simcall);
63 SIMIX_process_sleep_destroy(this);