From 747e522c7e6ba4e58a268488e8008ef19759b35b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 3 Nov 2023 02:33:02 +0100 Subject: [PATCH] Scheduler: design-problems while integrating deadline the attempt to integrate additional deadline and significance parameters unveils a design problem due to the layering of contexts - the Activity-Language attempts to abstract away the ''Scheduler mechanics'' - but this implementation logic now needs to pass additional parameters - and notably there is the possibility of direct re-scheduling from within the Activity-Dispatch The symptom of this problem is that it's no longer possible to implement the ExecutionCtx.post() function in the real Scheduler-context --- src/vault/gear/scheduler-commutator.hpp | 12 +- src/vault/gear/scheduler.hpp | 26 +++- .../vault/gear/scheduler-invocation-test.cpp | 1 - wiki/thinkPad.ichthyo.mm | 126 +++++++++++++----- 4 files changed, 123 insertions(+), 42 deletions(-) diff --git a/src/vault/gear/scheduler-commutator.hpp b/src/vault/gear/scheduler-commutator.hpp index 8f5046c66..e36c6bae4 100644 --- a/src/vault/gear/scheduler-commutator.hpp +++ b/src/vault/gear/scheduler-commutator.hpp @@ -218,7 +218,13 @@ namespace gear { activity::Proc postDispatch (Activity* chain, Time when ,EXE& executionCtx - ,SchedulerInvocation& layer1) + ,SchedulerInvocation& layer1 + //////////////////////////////////////////////////////////////////////////////////////////////OOO API / Design problem with "context" and significance-Params + , Time dead =Time::NEVER //////////////////////////////////TODO booom!! + , ManifestationID manID =ManifestationID() + , bool compulsory = false + //////////////////////////////////////////////////////////////////////////////////////////////OOO API / Design problem with "context" and significance-Params + ) { if (!chain) return activity::SKIP; @@ -227,9 +233,9 @@ namespace gear { return ActivityLang::dispatchChain (chain, executionCtx); else if (holdsGroomingToken (thisThread())) - layer1.feedPrioritisation (*chain, when); + layer1.feedPrioritisation (*chain, when, dead, manID, compulsory); else - layer1.instruct (*chain, when); + layer1.instruct (*chain, when, dead, manID, compulsory); return activity::PASS; } }; diff --git a/src/vault/gear/scheduler.hpp b/src/vault/gear/scheduler.hpp index fdd93ca78..6b3901eca 100644 --- a/src/vault/gear/scheduler.hpp +++ b/src/vault/gear/scheduler.hpp @@ -254,6 +254,12 @@ namespace gear { UNIMPLEMENTED("wrap the ActivityTerm"); } + //////////////////////////////////////////////////////////////////////////////////////////////OOO the role of this function remains unclear; currently used from »Tick« + activity::Proc postChain (Activity*, Time start + , Time dead =Time::ANYTIME + , ManifestationID manID =ManifestationID() + , bool isCompulsory = false); + /** * The worker-Functor: called by the active Workers from the @@ -500,6 +506,18 @@ namespace gear { } + //////////////////////////////////////////////////////////////////////////////////////////////OOO the role of this function remains unclear; currently used from »Tick« + inline activity::Proc + Scheduler::postChain (Activity* chain, Time start, Time dead + ,ManifestationID manID, bool isCompulsory) + { + auto& ctx = ExecutionCtx::from (*this); + return layer2_.postDispatch (chain, start, ctx, layer1_ + //////////////////////////////////////////////////////////////////////////////////////////////OOO API / Design problem with "context" and significance-Params + ,dead,manID,isCompulsory); + } + + /** * »Tick-hook« : code to maintain sane running status. * This function will be invoked [regularly](\ref DUTY_CYCLE_PERIOD) while the scheduler @@ -517,7 +535,10 @@ namespace gear { { // consolidate queue content layer1_.feedPrioritisation(); - //////////////////////////////////////////////////////////////////////OOO clean-up of outdated tasks here + // clean-up of outdated tasks here + while (layer1_.isOutdated (now) and not layer1_.isOutOfTime(now)) + layer1_.pullHead(); + // protect against missing the deadline of a compulsory task if (layer1_.isOutOfTime (now)) { triggerEmergency(); @@ -533,9 +554,8 @@ namespace gear { {// prepare next duty cycle »tick« Time nextTick = now + DUTY_CYCLE_PERIOD; Time deadline = nextTick + DUTY_CYCLE_TOLERANCE; - auto& ctx = ExecutionCtx::from (*this); Activity& tickActivity = activityLang_.createTick (deadline); - ctx.post(nextTick, &tickActivity, ctx); + postChain (&tickActivity, nextTick, deadline, ManifestationID(), true); } } diff --git a/tests/vault/gear/scheduler-invocation-test.cpp b/tests/vault/gear/scheduler-invocation-test.cpp index 55dd05483..8dfbec9c7 100644 --- a/tests/vault/gear/scheduler-invocation-test.cpp +++ b/tests/vault/gear/scheduler-invocation-test.cpp @@ -28,7 +28,6 @@ #include "lib/test/run.hpp" #include "vault/gear/scheduler-invocation.hpp" #include "lib/util.hpp" -#include "lib/test/diagnostic-output.hpp"///////////////////TODO using test::Test; using util::isSameObject; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3bd271f75..b442927be 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -80655,8 +80655,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + @@ -83846,18 +83847,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - - - + + + + + - - + + @@ -83907,6 +83908,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + +
@@ -84052,9 +84056,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + + + +
@@ -84090,8 +84097,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -84220,27 +84227,26 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
brauche generische Informationsfunktion isOutdated()

- - +
- - - + + + - - - + + + - + @@ -84285,11 +84291,52 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + +

+ das heißt, das ist latent ein Design-Problem — welches ich derzeit nicht lösen kann, da mir der Gesamtüberblick noch fehlt, und ich genau deshalb dieses offene Design gewählt habe +

+ + +
+ +
+ + + + + + +

+ kann es auch gar nicht, denn die Activity selber kennt i.A. keine Deadline +

+ + +
+
+ + + + + + + + + + + + - + @@ -84323,8 +84370,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
damit: direkt in findWork(now)

- - +
@@ -95418,13 +95464,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - - - - + + + + @@ -95519,14 +95565,14 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - + + + - + - - + + @@ -95538,6 +95584,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + +

+ derzeit eingestellt auf 50ms +

+ +
+