Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: no need for a depends() method in Observers
[simgrid.git] / src / kernel / actor / SimcallObserver.cpp
1 /* Copyright (c) 2019-2022. 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/actor/SimcallObserver.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "src/kernel/activity/CommImpl.hpp"
9 #include "src/kernel/activity/MailboxImpl.hpp"
10 #include "src/kernel/actor/ActorImpl.hpp"
11 #include "src/mc/mc_config.hpp"
12
13 #include <sstream>
14
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_observer, mc, "Logging specific to MC simcall observation");
16
17 namespace simgrid {
18 namespace kernel {
19 namespace actor {
20
21 void SimcallObserver::serialize(std::stringstream& stream) const
22 {
23   stream << (short)mc::Transition::Type::UNKNOWN;
24 }
25 void RandomSimcall::serialize(std::stringstream& stream) const
26 {
27   stream << (short)mc::Transition::Type::RANDOM << ' ';
28   stream << min_ << ' ' << max_;
29 }
30
31 void RandomSimcall::prepare(int times_considered)
32 {
33   next_value_ = min_ + times_considered;
34   XBT_DEBUG("MC_RANDOM(%d, %d) will return %d after %d times", min_, max_, next_value_, times_considered);
35 }
36
37 int RandomSimcall::get_max_consider()
38 {
39   return max_ - min_ + 1;
40 }
41
42 bool ConditionWaitSimcall::is_enabled()
43 {
44   static bool warned = false;
45   if (not warned) {
46     XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk");
47     warned = true;
48   }
49   return true;
50 }
51
52 bool SemAcquireSimcall::is_enabled()
53 {
54   static bool warned = false;
55   if (not warned) {
56     XBT_INFO("Using semaphore in model-checked code is still experimental. Use at your own risk");
57     warned = true;
58   }
59   return true;
60 }
61
62 } // namespace actor
63 } // namespace kernel
64 } // namespace simgrid