X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=results.mtask.tex;h=a939d4f4b2f4447295eed77854d34e35c8803d21;hb=a182f0a12fdb361d341337ce8240cbcd6ca96ebc;hp=888b0d67a9a60ae2b5793abde8e0ef5bbd2a248f;hpb=5fef9ca5f782e58aca5c019c71db675e16138b4d;p=msc-thesis1617.git diff --git a/results.mtask.tex b/results.mtask.tex index 888b0d6..a939d4f 100644 --- a/results.mtask.tex +++ b/results.mtask.tex @@ -7,7 +7,7 @@ solve. A type --- housing the \gls{EDSL} --- does not have to implement all the available classes. Moreover, classes can be added at will without interfering with the existing views. -\section{Semantics} +\section{\gls{Task} Semantics} The current \gls{mTask} engine for devices does not support \glspl{Task} in the sense that the \gls{C}-view does. \Glspl{Task} used with the \gls{C}-view are a main program that executes code and launches \glspl{Task}. It was also possible @@ -38,7 +38,7 @@ reflected in the \CI{MTTask} message type. press of a button. \end{itemize} -\subsection{\glspl{SDS}} +\section{\gls{SDS} semantics} \Glspl{SDS} on a client are available on the server as well as regular \gls{SDS}. However, the same freedom is not given on the \glspl{SDS} that reside on the client. Not all types are suitable to be located on a client. @@ -60,7 +60,7 @@ class sdspub v where pub :: (v t Upd) -> v t Expr | type t \end{lstlisting} -\section{Bytecode compilation}\label{sec:compiler} +\section{Bytecode compilation view}\label{sec:compiler} The \glspl{mTask} are sent to the device in bytecode and are saved in the memory of the device. To compile the \gls{EDSL} code to bytecode, a view is added to the \gls{mTask}-system encapsulated in the type \CI{ByteCode}. As @@ -113,7 +113,6 @@ instance arith ByteCode instance serial ByteCode \end{lstlisting} -\section{Implementation} \subsection{Instruction Set} The instruction set is given in Listing~\ref{bc:instr}. The instruction set is kept large, but under $255$, to get the highest expressively while keeping all @@ -274,7 +273,7 @@ makeStore [BCDigitalRead i] = [BCDigitalWrite i] makeStore [...] = [...] \end{lstlisting} -\section{Actual Compilation} +\subsection{Actual Compilation} All the previous functions are tied together with the \CI{toMessages} function. This function compiles the bytecode and transforms the \gls{Task} in a message. The \glspl{SDS} that were not already sent to the device are also added as @@ -311,7 +310,7 @@ toMessages interval x oldstate = ([MTSds sdsi e\\{sdsi,sdsval=e}<-newsdss] ++ [MTTask interval bc], newstate) \end{lstlisting} -\section{Example} +\section{Examples} The heating example given previously in Listing~\ref{lst:exmtask} would be compiled to the following code. The left column indicates the position in the program memory. @@ -327,51 +326,5 @@ position in the program memory. 17-19: BCPush (Bool 0) //Else label 20 : BCDigitalWrite (Digital D0) \end{lstlisting} - -\section{Interpreter} -The client contains an interpreter to execute a \gls{Task}'s bytecode. - -Before execution some preparatory work is done. The stack will be initialized -and the program counter and stack pointer are set to zero and the bottom -respectively. Then, the interpreter executes one step at the time while the -program counter is smaller than the program length. The code for this is listed -in Listing~\ref{lst:interpr}. One execution step is basically a big switch -statement going over all possible bytecode instructions. Some instructions are -detailed upon in the listing. The \CI{BCPush} instruction is a little more -complicated in real life because some decoding will take place as not all -\CI{BCValue}'s are of the same length. - -\begin{lstlisting}[language=C,label={lst:interpr},% - caption={Rough code outline for interpretation}] -#define f16(p) program[pc]*265+program[pc+1] - -void run_task(struct task *t){ - uint8_t *program = t->bc; - int plen = t->tasklength; - int pc = 0; - int sp = 0; - while(pc < plen){ - switch(program[pc++]){ - case BCNOP: - break; - case BCPUSH: - stack[sp++] = pc++ //Simplified - break; - case BCPOP: - sp--; - break; - case BCSDSSTORE: - sds_store(f16(pc), stack[--sp]); - pc+=2; - break; - // ... - case BCADD: trace("add"); - stack[sp-2] = stack[sp-2] + stack[sp-1]; - sp -= 1; - break; - // ... - case BCJMPT: trace("jmpt to %d", program[pc]); - pc = stack[--sp] ? program[pc]-1 : pc+1; - break; -} -\end{lstlisting} +\todo{More elaborate example} +\todo{Add return instruction}