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 <simgrid/s4u/host.hpp>
8 #include "src/kernel/activity/SynchroExec.hpp"
9 #include "src/surf/surf_interface.hpp"
10 #include "src/simix/smx_host_private.h"
12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
14 simgrid::kernel::activity::Exec::Exec(const char*name, sg_host_t hostarg)
18 this->state = SIMIX_RUNNING;
22 simgrid::kernel::activity::Exec::~Exec()
27 timeoutDetector->unref();
29 void simgrid::kernel::activity::Exec::suspend()
31 XBT_VERB("This exec is suspended (remain: %f)", surf_exec->getRemains());
36 void simgrid::kernel::activity::Exec::resume()
38 XBT_VERB("This exec is resumed (remain: %f)", surf_exec->getRemains());
43 double simgrid::kernel::activity::Exec::remains()
45 if (state == SIMIX_RUNNING)
46 return surf_exec->getRemains();
51 void simgrid::kernel::activity::Exec::post()
53 if (host && host->isOff()) {/* FIMXE: handle resource failure for parallel tasks too */
54 /* If the host running the synchro failed, notice it. This way, the asking
55 * process can be killed if it runs on that host itself */
57 } else if (surf_exec->getState() == simgrid::surf::Action::State::failed) {
58 /* If the host running the synchro didn't fail, then the synchro was canceled */
59 state = SIMIX_CANCELED;
60 } else if (timeoutDetector && timeoutDetector->getState() == simgrid::surf::Action::State::done) {
61 state = SIMIX_TIMEOUT;
70 if (timeoutDetector) {
71 timeoutDetector->unref();
72 timeoutDetector = nullptr;
75 /* If there are simcalls associated with the synchro, then answer them */
76 if (!simcalls.empty())
77 SIMIX_execution_finish(this);