Scheduler: implementation technology

- use Boost-Lockfree as entrance queue for instructions
- use the STL Heap-Algo and Priority-Queue adaptor for time order
This commit is contained in:
Fischlurch 2023-06-25 01:02:12 +02:00
parent 3169ba88ad
commit bdcfc94b57
2 changed files with 131 additions and 1 deletions

View file

@ -41,10 +41,12 @@
#include "vault/common.hpp"
#include "lib/nocopy.hpp"
//#include "lib/symbol.hpp"
#include "vault/gear/activity.hpp"
//#include "lib/util.hpp"
//#include <string>
#include <queue>
#include <boost/lockfree/queue.hpp>
namespace vault{
namespace gear {
@ -62,6 +64,17 @@ namespace gear {
class SchedulerInvocation
: util::NonCopyable
{
struct ActOrder
{
size_t waterlevel{0};
Activity* activity{nullptr};
};
using InstructQueue = boost::lockfree::queue<ActOrder>;
using PriorityQueue = std::priority_queue<ActOrder>;
InstructQueue instruct_;
PriorityQueue priority_;
public:
explicit

View file

@ -77935,6 +77935,35 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684973294743" ID="ID_495348423" MODIFIED="1684973356775" TEXT="Strukturen und Repr&#xe4;sentation">
<arrowlink COLOR="#fe6d01" DESTINATION="ID_1599285907" ENDARROW="Default" ENDINCLINATION="-183;0;" ID="Arrow_ID_1756942771" STARTARROW="None" STARTINCLINATION="-502;-42;"/>
<icon BUILTIN="flag-yellow"/>
<node CREATED="1687653152145" ID="ID_1131516416" MODIFIED="1687653156132" TEXT="Technologie">
<node CREATED="1687653184679" ID="ID_354837865" MODIFIED="1687653275259" TEXT="Priority-Queue">
<arrowlink COLOR="#7583c0" DESTINATION="ID_625176524" ENDARROW="Default" ENDINCLINATION="-651;120;" ID="Arrow_ID_1958287800" STARTARROW="None" STARTINCLINATION="-260;47;"/>
<node CREATED="1687732117240" ID="ID_580535539" MODIFIED="1687732219469" TEXT="STL container adapter">
<icon BUILTIN="yes"/>
</node>
<node CREATED="1687732127545" ID="ID_291376393" MODIFIED="1687732213152" TEXT="using vector storage">
<icon BUILTIN="info"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1687732144741" ID="ID_1834089420" MODIFIED="1687732156107" TEXT="integrate custom allocator">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node CREATED="1687653184679" ID="ID_198688104" MODIFIED="1687653278515" TEXT="Lock-Free-Queue">
<arrowlink COLOR="#7583c0" DESTINATION="ID_424660746" ENDARROW="Default" ENDINCLINATION="-651;120;" ID="Arrow_ID_825595958" STARTARROW="None" STARTINCLINATION="-260;47;"/>
<node CREATED="1687732174107" ID="ID_1455746784" MODIFIED="1687732223133" TEXT="Boost - Lockfree">
<icon BUILTIN="yes"/>
</node>
<node CREATED="1687732186197" ID="ID_1593826102" MODIFIED="1687732225878" TEXT="Node based (linked list)">
<icon BUILTIN="info"/>
</node>
<node CREATED="1687732193467" ID="ID_1465560345" MODIFIED="1687732229088" TEXT="Multi producer/consumer">
<icon BUILTIN="info"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1687732230868" ID="ID_1042469307" MODIFIED="1687732238086" TEXT="integrade custom allocator">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1680565476652" ID="ID_1218283238" MODIFIED="1684973201854" TEXT="Dependency-Notification">
@ -78544,6 +78573,37 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node CREATED="1687652249218" ID="ID_1174002353" MODIFIED="1687652266192" TEXT="Overload und Priorit&#xe4;ts-Klassen">
<node CREATED="1687652267839" ID="ID_739691729" LINK="https://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling" MODIFIED="1687652334909" TEXT="was wir hier machen ist analog EDS">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
<b http-equiv="content-type" content="text/html; charset=utf-8">Earliest deadline first</b>&#160;(<b>EDF</b>) or <b>least time to go</b>&#160;is a dynamic priority <a href="https://en.wikipedia.org/wiki/Scheduling_algorithm" class="mw-redirect" title="Scheduling algorithm">scheduling algorithm</a>&#160;used in <a href="https://en.wikipedia.org/wiki/Real-time_operating_system" title="Real-time operating system">real-time operating systems</a>&#160;to place processes in a <a href="https://en.wikipedia.org/wiki/Priority_queue" title="Priority queue">priority queue</a>. Whenever a scheduling event occurs (task finishes, new task released, etc.) the queue will be searched for the process closest to its deadline. This process is the next to be scheduled for execution.
</p>
</body>
</html></richcontent>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1687652356899" ID="ID_1155443486" MODIFIED="1687652375875" TEXT="K&#xf6;nnen Priorit&#xe4;ts-Klassen &#xfc;berhaupt dargestellt werden?">
<icon BUILTIN="help"/>
<node CREATED="1687652377638" ID="ID_927055665" MODIFIED="1687652408889" TEXT="z.B. Realtime vs. Background"/>
<node CREATED="1687652466615" ID="ID_98119896" MODIFIED="1687652589634" TEXT="der Background-Task k&#xf6;nnte eine fr&#xfc;here Deadline haben....">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
...und w&#252;rde dann strikt nach zeit-Ordnung zuerst bedient, und damit dem Realtime-Task die Ressourcen wegnehmen
</p>
</body>
</html></richcontent>
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
</node>
<node CREATED="1685320663808" ID="ID_503599380" MODIFIED="1685320675723" TEXT="Struktur-Elemente">
<linktarget COLOR="#f9ffd5" DESTINATION="ID_503599380" ENDARROW="Default" ENDINCLINATION="-127;-352;" ID="Arrow_ID_215108045" SOURCE="ID_779629114" STARTARROW="None" STARTINCLINATION="-65;91;"/>
@ -83257,6 +83317,63 @@ class Something
</node>
</node>
</node>
<node CREATED="1687648927947" ID="ID_1380476359" MODIFIED="1687648930939" TEXT="Library">
<node CREATED="1687648934225" ID="ID_614037719" MODIFIED="1687648936717" TEXT="Container">
<node CREATED="1687648937664" ID="ID_625176524" MODIFIED="1687653278515" TEXT="Priority-Queue">
<linktarget COLOR="#7583c0" DESTINATION="ID_625176524" ENDARROW="Default" ENDINCLINATION="-651;120;" ID="Arrow_ID_1958287800" SOURCE="ID_354837865" STARTARROW="None" STARTINCLINATION="-260;47;"/>
<node CREATED="1687648947496" ID="ID_703993096" MODIFIED="1687648959962" TEXT="in der STL ist ein Container-Adapter">
<node CREATED="1687648960777" ID="ID_361076856" MODIFIED="1687649036529" TEXT="per Default verwendet es einen Vektor als Storage"/>
<node CREATED="1687649037324" ID="ID_1052972991" MODIFIED="1687649084817" TEXT="und verwendet die Heap-Funktionen aus der Algorithms Library"/>
</node>
<node CREATED="1687649199093" ID="ID_1238297485" MODIFIED="1687650069175" TEXT="Top = front() | Hinzuf&#xfc;gen/L&#xf6;schen auf back()">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
Eine <i>St&#246;rstelle</i>&#160;in der Heap-Struktur wird durch &#8222;lokales bouble&#8220; korrigiert. Ein am Ende hinzugef&#252;gtes Element boubled hoch, bis es gr&#246;&#223;er ist als beide Kinder. F&#252;r ein entferntes gr&#246;&#223;tes Element rutscht das gr&#246;&#223;ere Kind hoch. F&#252;r ein entferntes inneres Element wird zun&#228;chst das letzte Element an diese Stelle gesetzt&#160;&#160;(weil dadurch dann die letzte Position frei wird); die dadurch entstehende St&#246;rstelle wird dann nach oben/unten korrigiert: ist das Element gr&#246;&#223;er als der Vater, tauscht es mit diesem, ist es kleiner als das gr&#246;&#223;ere seiner Kinder, tauscht es mit diesem.
</p>
</body>
</html></richcontent>
</node>
<node CREATED="1687649003288" ID="ID_897627121" MODIFIED="1687649023977" TEXT="Heap-Struktur wird per Vertauschen aufrechterhalten"/>
</node>
<node CREATED="1687648937664" ID="ID_424660746" MODIFIED="1687653275260" TEXT="Lock-Free-Queue">
<linktarget COLOR="#7583c0" DESTINATION="ID_424660746" ENDARROW="Default" ENDINCLINATION="-651;120;" ID="Arrow_ID_825595958" SOURCE="ID_198688104" STARTARROW="None" STARTINCLINATION="-260;47;"/>
<node CREATED="1687653343430" ID="ID_129816705" LINK="https://www.boost.org/doc/libs/1_67_0/doc/html/lockfree.html" MODIFIED="1687653358153" TEXT="Boost.Lockfree">
<node CREATED="1687653372315" ID="ID_822778764" MODIFIED="1687653830624" TEXT="Diskussion Boost vs. etwas anderes">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
...hatte ich vor einigen Jahren schon durchgef&#252;hrt. Die Boost-Impl wird weithin empfohlen, sie kommt einer Standard-Lib am n&#228;chsten. F&#252;r Ringbuffer gibt es diverse Alternativen, aber f&#252;r Multi-Producer / Multi-Consumer-Queue habe ich ansonsten nur Einzelfall-Implementierungen gefunden
</p>
</body>
</html></richcontent>
</node>
<node CREATED="1687653830614" ID="ID_1870061916" LINK="https://www.boost.org/doc/libs/1_67_0/doc/html/lockfree/rationale.html#lockfree.rationale.data_structures" MODIFIED="1687653842707" TEXT="Rationale: gew&#xe4;hlte Algos mit Quellangabe">
<icon BUILTIN="info"/>
</node>
<node CREATED="1687653915052" ID="ID_1274176286" MODIFIED="1687653922352" TEXT="Impl-Hinweise">
<node CREATED="1687653923297" ID="ID_891449088" MODIFIED="1687653940315" TEXT="Queue und Stack sind Node-based (Linked Lists)"/>
<node CREATED="1687653941495" ID="ID_206927451" MODIFIED="1687653950522" TEXT="Memory-Management verwendet Pooling mit Free-List"/>
</node>
</node>
<node CREATED="1687654335015" ID="ID_1304201442" LINK="https://www.boost.org/doc/libs/1_67_0/doc/html/boost/lockfree/queue.html" MODIFIED="1687654349447" TEXT="Lockfree Queue(Boost)">
<node CREATED="1687654475929" ID="ID_1328092870" MODIFIED="1687654481634" TEXT="Anforderungen Payload">
<node CREATED="1687654482640" ID="ID_1083159425" MODIFIED="1687654491804" TEXT="erfordert Copy-Konstruktor"/>
<node CREATED="1687654492258" ID="ID_737130580" MODIFIED="1687654499908" TEXT="trivial assign und Destruktor"/>
</node>
<node CREATED="1687654812074" ID="ID_74917801" MODIFIED="1687654839565" TEXT="man kann Alloaktions-Pool initial belegen">
<icon BUILTIN="idea"/>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1636143147825" ID="ID_224980157" MODIFIED="1636143159589" TEXT="Assembly">
<node CREATED="1636143161969" ID="ID_1119605136" MODIFIED="1636143179445" TEXT="r?x : 64-Bit-Regixter"/>
<node CREATED="1636143180154" ID="ID_858272401" MODIFIED="1636143194684" TEXT="e?x : 32-Bit-Sicht auf die gleichen Register">