b4a15043b39b1f1bb63bd4a91d9bb9f4b0971338
[msc-thesis1617.git] / pres.system.tex
1 \subsection{Overview}
2 \begin{frame}
3 \frametitle{Current state of mTask}
4 \begin{itemize}
5 \item It all seems perfect
6 \item \ldots\pause{} but\ldots
7 \pause{}
8 \item No interaction
9 \item Compilation requires reprogramming
10 \item Entire system is created and fixed
11 \end{itemize}
12 \end{frame}
13
14 \begin{frame}
15 \frametitle{Solution}
16 \begin{itemize}[<+->]
17 \item New bytecode backend for mTask
18 \item Interpreter on client
19 \item Server in iTasks with integration
20 \item No taskserver generation, onetime programming
21 \item Dynamic task sending
22 \item Explicit SDS publishing
23 \end{itemize}
24 \end{frame}
25
26 \subsection{Extending mTask}
27 \begin{frame}[fragile]
28 \frametitle{Adding a View}
29 \begin{lstlisting}
30 :: ByteCode a p = BC (RWS () [BC] BCState ())
31 :: BC = BCNop | BCPush BCValue | ...
32 :: BCValue = E.e: BCValue e & mTaskType, TC e
33 :: BCShare = { sdsi :: Int, sdsval :: BCValue, sdsname :: String }
34 :: BCState = { freshl :: Int, freshs :: Int, sdss :: [BCShare] }
35
36 instance ByteCode arith, boolExpr, ...
37 \end{lstlisting}
38 \end{frame}
39
40 \begin{frame}[fragile]
41 \frametitle{Implementation}
42 \begin{itemize}
43 \item Writing instruction
44 \item Carrying state
45 \item Hand-crafted helpers
46 \end{itemize}
47 \begin{lstlisting}
48 op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr
49 op2 (BC x) (BC y) bc = BC (x >>| y >>| tell [bc])
50
51 tell2 :: [BC] -> (ByteCode a p)
52 tell2 x = BC (tell x)
53
54 instance arith ByteCode where
55 lit x = tell2 [BCPush (BCValue x)]
56 (+.) x y = op2 x y BCDiv
57 ...
58 \end{lstlisting}
59 \end{frame}
60
61 \begin{frame}[fragile]
62 \frametitle{Control flow}
63 \begin{itemize}
64 \item Use labels
65 \item Label resolving
66 \pause{}
67 \item Thus no reuse
68 \end{itemize}
69 \pause{}
70 \begin{lstlisting}
71 :: BC = ... | BCLab Int | ...
72
73 freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| pure freshl
74
75 instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e
76 ...
77 BCIfStmt (BC b) (BC t) (BC e) = BC (
78 freshlabel >>= \else->freshlabel >>= \endif->
79 b >>| tell [BCJmpF else] >>|
80 t >>| tell [BCJmp endif, BCLab else] >>|
81 e >>| tell [BCLab endif]
82 )
83 \end{lstlisting}
84 \end{frame}
85
86 %\begin{frame}[fragile]
87 % \frametitle{Functionality}
88 % \begin{block}{SDS scope and naming}
89 % \begin{itemize}
90 % \item SDS is lost
91 % \item State per device
92 % \item Tasks are sent and gone
93 % \end{itemize}
94 % \pause{}
95 % \begin{lstlisting}
96 %class namedsds v where
97 % namedsds :: ((v t Upd) -> In (Named t String) (Main (v c s)))
98 % -> (Main (v c s)) | ...
99 %:: Named a b = Named infix 1 a b
100 %
101 %instance sdspub ByteCode where
102 % pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
103 % \end{lstlisting}
104 % \end{block}
105 %\end{frame}
106
107 \begin{frame}[fragile]
108 \frametitle{Assignment}
109 \begin{lstlisting}
110 instance sds ByteCode where
111 sds f = {main = BC (freshshare
112 >>= \sdsi->pure {BCShare|sdsname="",sdsi=sdsi,sdsval=BCValue 0}
113 >>= \sds->pure (f (tell2 [BCSdsFetch sds]))
114 >>= \(v In bdy)->modify (addSDS sds v)
115 >>| unBC (unMain bdy))
116 }
117
118 instance assign ByteCode where
119 (=.) (BC v) (BC e) = BC (e >>| censor makeStore v)
120
121 instance sdspub ByteCode where
122 pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
123
124 makeStore [BCSdsFetch i] = [BCSdsStore i]
125 makeStore [BCDigitalRead i] = [BCDigitalWrite i]
126 makeStore [...] = [...]
127 \end{lstlisting}
128 \end{frame}
129
130 \begin{frame}[fragile]
131 \frametitle{Task scheduling}
132 \begin{block}{Old}
133 \begin{itemize}
134 \item Task server
135 \item Tasks start other tasks
136 \end{itemize}
137 \end{block}
138 \pause{}
139 \begin{block}{New}
140 \begin{itemize}
141 \item Old system, taskserver, tasks start tasks
142 \item New system, task+strategy
143 \pause{}
144 \begin{itemize}
145 \item \CI{OnShot}
146 \item \CI{OnInterval}
147 \item \CI{OnInterrupt}
148 \end{itemize}
149 \pause{}
150 \item How to handle termination
151 \end{itemize}
152 \pause{}
153 \begin{lstlisting}
154 class retrn v where
155 retrn :: v () Expr
156 \end{lstlisting}
157 \end{block}
158 \end{frame}
159
160 \subsection{Interpretation}
161 \begin{frame}[fragile]
162 \frametitle{mTask implementation}
163 %TODO
164 \end{frame}
165
166 \subsection{Devices}
167 \begin{frame}
168 \frametitle{Devices}
169 \begin{itemize}
170 \item Standard C
171 \item Implement some classes in interface
172 \pause{}
173 \item How to handle termination
174 \end{itemize}
175 \end{frame}
176
177 \subsection{Server}
178 \begin{frame}[fragile]
179 \frametitle{SDS (2)}
180 \framesubtitle{Parametric Lenses}
181 \begin{block}{What is the \CI{p} for in \CI{RWShared p r w}}
182 \pause{}
183 \begin{itemize}
184 \item Parameter fixed when writing
185 \item Used for notifications
186 \item On write the SDS returns \CI{p -> Bool}
187 \end{itemize}
188 \end{block}
189 %
190 % \begin{lstlisting}
191 %sdsFocus :: p1 (RWShared p1 r w) -> RWShared p2 r w | iTask p
192 %
193 %:: SDSNotifyPred p :== p -> Bool
194 %:: SDSLensRead p r rs = SDSRead (p -> rs -> MaybeError TaskException r)
195 % | SDSReadConst (p -> r)
196 %:: SDSLensWrite p w rs ws = SDSWrite (p -> rs -> w -> MaybeError TaskException (Maybe ws))
197 % | SDSWriteConst (p -> w -> MaybeError TaskException (Maybe ws))
198 %:: SDSLensNotify p w rs = SDSNotify (p -> rs -> w -> SDSNotifyPred p)
199 % | SDSNotifyConst (p -> w -> SDSNotifyPred p)
200 %
201 %sdsLens :: String (p -> ps) (SDSLensRead p r rs) (SDSLensWrite p w rs ws)
202 % (SDSLensNotify p w rs) (RWShared ps rs ws) -> RWShared p r w | iTask ps
203 % \end{lstlisting}
204 \end{frame}
205 \subsection{Examples}