X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=results.mtask.tex;h=2ad243a5a03089d378e917f884fb496b883988d3;hb=e0645e1487f71512352f4fe8ace2e7a8e1e73d71;hp=c32f7acf318e05ad9d6a03f3404b136458d6b089;hpb=9662cccfffecb70d621318b5f3a35e46b6029f3c;p=msc-thesis1617.git diff --git a/results.mtask.tex b/results.mtask.tex index c32f7ac..2ad243a 100644 --- a/results.mtask.tex +++ b/results.mtask.tex @@ -1,36 +1,72 @@ -Some functionality of the original \gls{mTask}-\gls{EDSL} will not be used in -this extension \gls{EDSL}. Conversely, some functionality needed was not -available in the existing \gls{EDSL}. Due to the nature of class based shallow -embedding this obstacle is very easy to 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. +The \glspl{Task} suitable for a client are called \glspl{mTask} and are written +in the aforementioned \gls{mTask}-\gls{EDSL}. Some functionality of the +original \gls{mTask}-\gls{EDSL} will not be used in this extension \gls{EDSL}. +Conversely, some functionality needed was not available in the existing +\gls{EDSL}. Due to the nature of class based shallow embedding this obstacle is +very easy to 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} -\subsection{\glspl{mTask}} The current \gls{mTask} engine for devices does not support \glspl{Task} in the -sense that the \gls{C}-view it does. \glspl{Task} in the new system are are -\CI{Main} objects with a program inside. A \gls{Task} runs periodically, on -interrupt or one-shot. -\todo{elaborate} +sense that the \gls{C}-view it does. \Glspl{Task} used with the \gls{C}-view +are a main program that runs some \gls{Task}. \glspl{Task} in the new system +are \CI{Main} objects with a program inside that does not contain \glspl{Task} +but are a \gls{Task} as a whole. Sending a \gls{Task} always goes together with +choosing a scheduling strategy. This strategy can be one of the following three +strategies as reflected in the \CI{MTTask}. + +\begin{itemize} + \item\CI{OneShot} + + \CI{OneShot} takes no parameters and means that the \gls{Task} will run + once and will then be removed automatically. This type of scheduling + could be usefull to for example retrieving sensor information on + request of a user. + \item\CI{OnInterval} + + \CI{OnInterval} has as a parameter the number of milliseconds to wait + in between executions. \Glspl{Task} running with this scheduling method + are executed every fixed interval. + \item\CI{OnInterrupt} + + The last scheduling method is running \glspl{Task} on a specific + interrupt. None of the current implementation implement this. However, + registering interrupts on for example the \gls{Arduino} is very + straightforward. Interrupt scheduling is usefull for \glspl{Task} that + have to react on a certain type of hardware event such as the press of + a button. +\end{itemize} \subsection{\glspl{SDS}} -\glspl{SDS} behave a little bit differently on an \gls{mTask} device than in -the \gls{iTasks} system. In an \gls{iTasks} system, when the \gls{SDS} is -updated, a broadcast to everyone in the system watching is made to notify them -of an update. \glspl{SDS} on the device can update very often and the update -might not be the final value it will get. Therefore a device must publish the -\gls{SDS} explicitly to save bandwidth. This means that an extra function is -added to the \CI{sds} class that adds the \CI{pub} function. -\todo{elaborate} +\Glspl{SDS} on a client are available on the server as well. 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. Moreover, \glspl{SDS} behave a +little bit differently on an \gls{mTask} device than in the \gls{iTasks} +system. In an \gls{iTasks} system, when the \gls{SDS} is updated, a broadcast +to everyone in the system watching is made to notify them of an update. +\glspl{SDS} on the device can update very often and the update might not be the +final value it will get. Therefore a device must publish the \gls{SDS} +explicitly to save bandwidth. + +To add this functionality, the \CI{sds} class could be extended. However, this +would result in having to update all existing views that use the \CI{sds} +class. Therefore, an extra class is added that contains the extra +functionality. The existing views can choose to implement it in the future but +are not obliged to. The publication function has the following signature: +\begin{lstlisting}[caption={The \texttt{sdspub} class}] +class sdspub v where + pub :: (v t Upd) -> v t Expr | type t +\end{lstlisting} \section{Bytecode compilation}\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 called \CI{ByteCode}. As shown in -Listing~\ref{lst:bcview}, the \CI{ByteCode} view is a boxed \gls{RWST} that -writes bytecode instructions (\CI{BC}) while carrying around a \CI{BCState}. -The state is kept between devices and contains fresh variable names and a -register of shares used. +added to the \gls{mTask}-system encapsulated in the type \CI{ByteCode}. As +shown in Listing~\ref{lst:bcview}, the \CI{ByteCode} view is a boxed \gls{RWST} +that writes bytecode instructions (\CI{BC}) while carrying around a +\CI{BCState}. The state is kept between compilations and is unique to a device. +The state contains fresh variable names and a register of shares used. Types implementing the \gls{mTask} classes must have two free type variables. Therefore the \gls{RWST} is wrapped with a constructor and two phantom type @@ -211,6 +247,7 @@ instance sds ByteCode where >>= \(v In bdy)->modify (addSDS sds v) >>| unBC (unMain bdy)) } +instance sdspub ByteCode where pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x) addSDS sds v s = {s & sdss=[{sds & sdsval=BCValue v}:s.sdss]} @@ -288,3 +325,6 @@ position in the program memory. \end{lstlisting} \todo{add more elaborate example?} + +\section{Interpretation} +\todo{details about the interpreter on the client}