Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e954fae5a6a20e1b4e54e2257e80ad64559d952e
[simgrid.git] / src / kernel / activity / SynchroIo.cpp
1 /* Copyright (c) 2007-2016. 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/SynchroIo.hpp"
7 #include "src/simix/smx_private.h"
8 #include "src/surf/FileImpl.hpp"
9 #include "src/surf/StorageImpl.hpp"
10 #include "src/surf/surf_interface.hpp"
11
12 void simgrid::kernel::activity::IoImpl::suspend()
13 {
14   if (surf_io)
15     surf_io->suspend();
16 }
17
18 void simgrid::kernel::activity::IoImpl::resume()
19 {
20   if (surf_io)
21     surf_io->resume();
22 }
23
24 void simgrid::kernel::activity::IoImpl::post()
25 {
26   for (smx_simcall_t simcall : simcalls) {
27     switch (simcall->call) {
28     case SIMCALL_FILE_WRITE:
29       simcall_file_write__set__result(simcall, surf_io->getCost());
30       break;
31
32     case SIMCALL_FILE_READ:
33       simcall_file_read__set__result(simcall, surf_io->getCost());
34       break;
35
36     default:
37       break;
38     }
39   }
40
41   switch (surf_io->getState()) {
42
43     case simgrid::surf::Action::State::failed:
44       state = SIMIX_FAILED;
45       break;
46
47     case simgrid::surf::Action::State::done:
48       state = SIMIX_DONE;
49       break;
50
51     default:
52       THROW_IMPOSSIBLE;
53       break;
54   }
55
56   SIMIX_io_finish(this);
57 }