Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: move the reversible_race logic to the Transition class
[simgrid.git] / src / mc / transition / TransitionSynchro.hpp
1 /* Copyright (c) 2015-2023. 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 #ifndef SIMGRID_MC_TRANSITION_SYNCHRO_HPP
7 #define SIMGRID_MC_TRANSITION_SYNCHRO_HPP
8
9 #include "src/mc/transition/Transition.hpp"
10
11 #include <cstdint>
12
13 namespace simgrid::mc {
14
15 class BarrierTransition : public Transition {
16   unsigned bar_;
17
18 public:
19   std::string to_string(bool verbose) const override;
20   BarrierTransition(aid_t issuer, int times_considered, Type type, std::stringstream& stream);
21   bool depends(const Transition* other) const override;
22   bool reversible_race(const Transition* other) const override;
23 };
24
25 class MutexTransition : public Transition {
26   uintptr_t mutex_;
27   aid_t owner_;
28
29 public:
30   std::string to_string(bool verbose) const override;
31   MutexTransition(aid_t issuer, int times_considered, Type type, std::stringstream& stream);
32   bool depends(const Transition* other) const override;
33   bool reversible_race(const Transition* other) const override;
34
35   uintptr_t get_mutex() const { return this->mutex_; }
36   aid_t get_owner() const { return this->owner_; }
37 };
38
39 class SemaphoreTransition : public Transition {
40   unsigned int sem_; // ID
41   bool granted_;
42   unsigned capacity_;
43
44 public:
45   std::string to_string(bool verbose) const override;
46   SemaphoreTransition(aid_t issuer, int times_considered, Type type, std::stringstream& stream);
47   bool depends(const Transition* other) const override;
48   bool reversible_race(const Transition* other) const override;
49
50   int get_capacity() const { return capacity_; }
51 };
52
53 } // namespace simgrid::mc
54
55 #endif