From a853851447666e8db229a742a35952c349373be9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 14 Dec 2016 04:18:58 +0100 Subject: [PATCH] add complete locking to the ProcDispatcher on both levels - the front-end needs locking to ensure consistent state (memory barrier) - the back-end nees locking to coordinate command processing --- src/proc/control/proc-dispatcher.cpp | 10 +++++++++ src/proc/control/proc-dispatcher.hpp | 2 ++ wiki/thinkPad.ichthyo.mm | 31 ++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index dc339edd5..1fa17cd7b 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -35,12 +35,15 @@ //using boost::str; using backend::ThreadJoinable; +using lib::Sync; +using lib::RecursiveLock_Waitable; namespace proc { namespace control { class DispatcherLoop : ThreadJoinable + , public Sync { public: DispatcherLoop (Subsys::SigTerm notification) @@ -93,6 +96,7 @@ namespace control { bool ProcDispatcher::start (Subsys::SigTerm termNotification) { + Lock sync(this); if (runningLoop_) return false; runningLoop_.reset ( @@ -111,6 +115,7 @@ namespace control { bool ProcDispatcher::isRunning() { + Lock sync(this); return bool(runningLoop_); } @@ -119,6 +124,7 @@ namespace control { void ProcDispatcher::requestStop() { + Lock sync(this); UNIMPLEMENTED ("trigger shutdown into the dispacher loop thread"); } @@ -127,6 +133,7 @@ namespace control { void ProcDispatcher::activate() { + Lock sync(this); INFO (command, "Session command processing activated."); ///////////////TODO only emit these log messages when processing is *really* started/stopped TODO ("implement command processing queue"); } @@ -135,6 +142,7 @@ namespace control { void ProcDispatcher::deactivate() { + Lock sync(this); INFO (command, "Session command interface closed."); TODO ("implement command processing queue"); } @@ -143,6 +151,7 @@ namespace control { void ProcDispatcher::clear() { + Lock sync(this); if (!empty()) WARN (command, "DISCARDING pending Session commands."); TODO ("implement command processing queue"); @@ -152,6 +161,7 @@ namespace control { bool ProcDispatcher::empty() const { + Lock sync(this); TODO ("implement command processing queue"); return true; } diff --git a/src/proc/control/proc-dispatcher.hpp b/src/proc/control/proc-dispatcher.hpp index c230f645c..95b485eff 100644 --- a/src/proc/control/proc-dispatcher.hpp +++ b/src/proc/control/proc-dispatcher.hpp @@ -38,6 +38,7 @@ //#include "lib/symbol.hpp" #include "common/subsys.hpp" #include "lib/depend.hpp" +#include "lib/sync.hpp" #include //#include @@ -60,6 +61,7 @@ namespace control { * @todo Type-comment */ class ProcDispatcher + : public lib::Sync<> { unique_ptr runningLoop_; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 48823baef..6aeaf4fa1 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -224,11 +224,34 @@ - - + + + + + + + + +

+ das Lock sorgt hier für konsistenten Zustand und Sichtbarkeit (memory barrier) +

+ + +
+
+ + + + + + +

+ Lock ist hier das Dispatcher-Lock +

+ + +
- -