1 /* Copyright (c) 2007-2016. 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 "src/simix/SynchroSleep.hpp"
7 #include "src/surf/surf_interface.hpp"
8 #include "src/simix/popping_private.h"
9 #include "src/simix/smx_process_private.h"
11 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
13 void simgrid::simix::Sleep::suspend()
15 surf_sleep->suspend();
18 void simgrid::simix::Sleep::resume()
23 void simgrid::simix::Sleep::post()
25 smx_simcall_t simcall;
28 while ((simcall = (smx_simcall_t) xbt_fifo_shift(simcalls))) {
30 switch (surf_sleep->getState()){
31 case simgrid::surf::Action::State::failed:
32 simcall->issuer->context->iwannadie = 1;
33 //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
34 state = SIMIX_SRC_HOST_FAILURE;
37 case simgrid::surf::Action::State::done:
45 if (simcall->issuer->host->isOff()) {
46 simcall->issuer->context->iwannadie = 1;
48 simcall_process_sleep__set__result(simcall, state);
49 simcall->issuer->waiting_synchro = NULL;
50 if (simcall->issuer->suspended) {
51 XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
52 simcall->issuer->suspended = 0;
53 simcall_HANDLER_process_suspend(simcall, simcall->issuer);
55 SIMIX_simcall_answer(simcall);
59 SIMIX_process_sleep_destroy(this);