From 047ee8a13310ba90d01934827cb17c680b32a4b5 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Thu, 1 Jun 2017 17:23:56 +0200 Subject: [PATCH] add pseudocode for the engine --- .chktexrc | 2 +- methods.mtask.tex | 44 +++++++++++++++++++++++++++++++++++++++----- thesis.loa | 10 ++++++++++ thesis.tex | 10 ++++++---- 4 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 thesis.loa diff --git a/.chktexrc b/.chktexrc index a9f06b0..91bb817 100644 --- a/.chktexrc +++ b/.chktexrc @@ -1,4 +1,4 @@ -VerbEnvir { lstlisting } +VerbEnvir { lstlisting algorithm } WipeArg { \CI:{} \texttt:{} diff --git a/methods.mtask.tex b/methods.mtask.tex index 5b6128d..db31782 100644 --- a/methods.mtask.tex +++ b/methods.mtask.tex @@ -36,11 +36,45 @@ instance isExpr Expr \end{lstlisting} \section{Semantics} -\gls{mTask} do not behave like functions but more like -\gls{iTasks}-\glspl{Task}. When an \gls{mTask} is created it returns immediatly -and the \gls{Task} will be executed sometime in the future. \glspl{Task} can -run at an interval and they can start other tasks. -\todo{Meer uitwijden over de mTask semantiek} +The \gls{C}-backend of the \gls{mTask}-system has an engine that is generated +alongside the code for the \glspl{Task}. This engine will execute the +\glspl{mTask} according to certain rules and semantics. +\glspl{mTask} do not behave like functions but more like +\gls{iTasks}-\glspl{Task}. An \gls{mTask} is queued when either his timer runs +out or when it is started by another \gls{mTask}. When an \gls{mTask} is +queued it does not block the execution but it will return immediately while +the actual \gls{Task} will be executed some time in the future. + +The \gls{iTasks}-backend simulates the \gls{C}-backend and thus uses the same +semantics. This engine expressed in pseudocode is listed as +Algorithm~\ref{lst:engine}. All the \glspl{Task} are inspected on their waiting +time. When the waiting time has not passed the delta is subtracted and they are +pushed to the end of the queue. When the waiting has has surpassed they are +executed. When a \gls{mTask} wants to queue another \gls{mTask} it can just +append it to the queue. + +\begin{algorithm}[H] + \KwData{\textbf{queue} queue$[]$, \textbf{time} $t, t_p$} + + $t\leftarrow\text{now}()$\; + \Begin{ + \While{true}{ + $t_p\leftarrow t$\; + $t\leftarrow\text{now}()$\; + \If{notEmpty$($queue$)$}{ + $task\leftarrow \text{queue.pop}()$\; + $task$.wait $-= t-t_p$\; + \eIf{$task.wait>t_0$}{ + queue.append$(task)$\; + }{ + run\_task$(task)$\; + } + } + } + } + \caption{Engine pseudocode for the \gls{C}- and + \gls{iTasks}-backends}\label{lst:engine} +\end{algorithm} \section{Expressions} Expressions in the \gls{mTask}-\gls{EDSL} are divided into two types, namely diff --git a/thesis.loa b/thesis.loa new file mode 100644 index 0000000..813f3bb --- /dev/null +++ b/thesis.loa @@ -0,0 +1,10 @@ +\addvspace {10\p@ } +\addvspace {10\p@ } +\addvspace {10\p@ } +\addvspace {10\p@ } +\contentsline {algocf}{\numberline {1}{\ignorespaces Engine pseudocode for the \gls {C}- and \gls {iTasks}-backends\relax }}{14}{algocf.1} +\addvspace {10\p@ } +\addvspace {10\p@ } +\addvspace {10\p@ } +\addvspace {10\p@ } +\addvspace {10\p@ } diff --git a/thesis.tex b/thesis.tex index 7b45b95..519f9c2 100644 --- a/thesis.tex +++ b/thesis.tex @@ -1,5 +1,6 @@ %&thesis -\usepackage[nonumberlist,acronyms]{glossaries} +\usepackage[nonumberlist,acronyms]{glossaries} % Glossaries and acronyms +\usepackage[]{algorithm2e} % Pseudocode \makeglossaries% \input{acronyms} @@ -83,9 +84,10 @@ \addcontentsline{toc}{chapter}{Lists of \ldots} \begingroup \let\clearpage\relax -\listoffigures -\listoftables -\lstlistoflistings{} +\listoffigures% +\listoftables% +\lstlistoflistings% +\listofalgorithms% \endgroup \end{document} -- 2.20.1