A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Prefer a reference for first parameter of {test,wait}_{all,any}.
[simgrid.git]
/
src
/
kernel
/
actor
/
SimcallObserver.hpp
diff --git
a/src/kernel/actor/SimcallObserver.hpp
b/src/kernel/actor/SimcallObserver.hpp
index a1a5936685467b415056c490889cbaed8b84a817..ccc4c7b73629b51f5df5f05e6049c9ad0d0e6546 100644
(file)
--- a/
src/kernel/actor/SimcallObserver.hpp
+++ b/
src/kernel/actor/SimcallObserver.hpp
@@
-48,7
+48,14
@@
public:
{ /* Nothing to do by default */
}
- /** Some simcalls may only be observable under some circumstances.
+ /** We need to save the observer of simcalls as they get executed to later compute their dependencies in classical
+ * DPOR */
+ virtual SimcallObserver* clone() = 0;
+
+ /** Computes the dependency relation */
+ virtual bool depends(SimcallObserver* other);
+
+ /** Some simcalls may only be observable under some conditions.
* Most simcalls are not visible from the MC because they don't have an observer at all. */
virtual bool is_visible() const { return true; }
virtual std::string to_string(int times_considered) const = 0;
@@
-71,34
+78,50
@@
class RandomSimcall : public SimcallObserver {
public:
RandomSimcall(smx_actor_t actor, int min, int max) : SimcallObserver(actor), min_(min), max_(max) {}
+ SimcallObserver* clone() override
+ {
+ auto res = new RandomSimcall(get_issuer(), min_, max_);
+ res->next_value_ = next_value_;
+ return res;
+ }
int get_max_consider() const override;
void prepare(int times_considered) override;
std::string to_string(int times_considered) const override;
std::string dot_label() const override;
int get_value() const { return next_value_; }
+ bool depends(SimcallObserver* other) override;
};
-class Mutex
Unlock
Simcall : public SimcallObserver {
-
using SimcallObserver::SimcallObserver
;
+class MutexSimcall : public SimcallObserver {
+
activity::MutexImpl* const mutex_
;
public:
+ MutexSimcall(smx_actor_t actor, activity::MutexImpl* mutex) : SimcallObserver(actor), mutex_(mutex) {}
+ activity::MutexImpl* get_mutex() const { return mutex_; }
+ bool depends(SimcallObserver* other) override;
+};
+
+class MutexUnlockSimcall : public MutexSimcall {
+ using MutexSimcall::MutexSimcall;
+
+public:
+ SimcallObserver* clone() override { return new MutexUnlockSimcall(get_issuer(), get_mutex()); }
std::string to_string(int times_considered) const override;
std::string dot_label() const override;
};
-class MutexLockSimcall : public SimcallObserver {
- activity::MutexImpl* const mutex_;
+class MutexLockSimcall : public MutexSimcall {
const bool blocking_;
public:
MutexLockSimcall(smx_actor_t actor, activity::MutexImpl* mutex, bool blocking = true)
- :
SimcallObserver(actor), mutex_(
mutex), blocking_(blocking)
+ :
MutexSimcall(actor,
mutex), blocking_(blocking)
{
}
+ SimcallObserver* clone() override { return new MutexLockSimcall(get_issuer(), get_mutex(), blocking_); }
bool is_enabled() const override;
std::string to_string(int times_considered) const override;
std::string dot_label() const override;
- activity::MutexImpl* get_mutex() const { return mutex_; }
};
class ConditionWaitSimcall : public ResultingSimcall<bool> {
@@
-112,6
+135,7
@@
public:
: ResultingSimcall(actor, false), cond_(cond), mutex_(mutex), timeout_(timeout)
{
}
+ SimcallObserver* clone() override { return new ConditionWaitSimcall(get_issuer(), cond_, mutex_, timeout_); }
bool is_enabled() const override;
bool is_visible() const override { return false; }
std::string to_string(int times_considered) const override;
@@
-130,6
+154,7
@@
public:
: ResultingSimcall(actor, false), sem_(sem), timeout_(timeout)
{
}
+ SimcallObserver* clone() override { return new SemAcquireSimcall(get_issuer(), sem_, timeout_); }
bool is_enabled() const override;
bool is_visible() const override { return false; }
std::string to_string(int times_considered) const override;
@@
-138,6
+163,23
@@
public:
double get_timeout() const { return timeout_; }
};
+class ActivityWaitSimcall : public ResultingSimcall<bool> {
+ activity::ActivityImpl* const activity_;
+ const double timeout_;
+
+public:
+ ActivityWaitSimcall(smx_actor_t actor, activity::ActivityImpl* activity, double timeout)
+ : ResultingSimcall(actor, false), activity_(activity), timeout_(timeout)
+ {
+ }
+ SimcallObserver* clone() override { return new ActivityWaitSimcall(get_issuer(), activity_, timeout_); }
+ bool is_visible() const override { return false; }
+ std::string to_string(int times_considered) const override { return SimcallObserver::to_string(times_considered); }
+ std::string dot_label() const override { return SimcallObserver::dot_label(); }
+ activity::ActivityImpl* get_activity() const { return activity_; }
+ double get_timeout() const { return timeout_; }
+};
+
class ExecutionWaitanySimcall : public ResultingSimcall<int> {
const std::vector<activity::ExecImpl*>& execs_;
const double timeout_;
@@
-147,6
+189,7
@@
public:
: ResultingSimcall(actor, -1), execs_(execs), timeout_(timeout)
{
}
+ SimcallObserver* clone() override { return new ExecutionWaitanySimcall(get_issuer(), execs_, timeout_); }
bool is_visible() const override { return false; }
std::string to_string(int times_considered) const override;
std::string dot_label() const override;
@@
-163,6
+206,7
@@
public:
: ResultingSimcall(actor, -1), ios_(ios), timeout_(timeout)
{
}
+ SimcallObserver* clone() override { return new IoWaitanySimcall(get_issuer(), ios_, timeout_); }
bool is_visible() const override { return false; }
std::string to_string(int times_considered) const override;
std::string dot_label() const override;