Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SIMIX_io_finish becomes IoImp::finish
[simgrid.git] / src / kernel / activity / SynchroRaw.cpp
1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/kernel/activity/SynchroRaw.hpp"
7 #include "simgrid/kernel/resource/Action.hpp"
8 #include "src/kernel/context/Context.hpp"
9 #include "src/simix/smx_synchro_private.hpp"
10 #include "src/surf/cpu_interface.hpp"
11 #include "src/surf/surf_interface.hpp"
12 #include <simgrid/s4u/Host.hpp>
13
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
15
16 namespace simgrid {
17 namespace kernel {
18 namespace activity {
19
20 RawImpl* RawImpl::start(s4u::Host* host, double timeout)
21 {
22   surf_action_ = host->pimpl_cpu->sleep(timeout);
23   surf_action_->set_data(this);
24   return this;
25 }
26
27 RawImpl::~RawImpl()
28 {
29   surf_action_->unref();
30 }
31
32 void RawImpl::suspend()
33 {
34   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
35 }
36
37 void RawImpl::resume()
38 {
39   /* I cannot resume raw synchros directly. This is delayed to when the process is rescheduled at
40    * the end of the synchro. */
41 }
42 void RawImpl::post()
43 {
44   XBT_IN("(%p)",this);
45   smx_simcall_t simcall = simcalls_.front();
46   simcalls_.pop_front();
47
48   SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
49   simcall->issuer->waiting_synchro = nullptr;
50
51   if (surf_action_->get_state() == resource::Action::State::FAILED) {
52     state_ = SIMIX_FAILED;
53     simcall->issuer->context_->iwannadie = true;
54   } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
55     state_ = SIMIX_SRC_TIMEOUT;
56     SIMIX_simcall_answer(simcall);
57   }
58   XBT_OUT();
59 }
60 } // namespace activity
61 } // namespace kernel
62 } // namespace simgrid