update
[msc-thesis1617.git] / conclusion.discussion.tex
1 The system is still a crude prototype and a proof of concept. Improvements and
2 extension for the system are amply available in several fields of study.
3
4 \subsection{Simulation}
5 An additional simulation view to the \gls{mTask}-\gls{EDSL} could be added that
6 works in the same way as the existing \gls{C}-backed simulation. It simulates
7 the bytecode interpretation. Moreover, it would also be possible to let the
8 simulator function as a real device, thus handling all communication through
9 the existing \gls{SDS}-based systems. At the moment the \emph{POSIX}-client is
10 the reference client and contains debugging code. Adding a simulation view to
11 the system allows for easy interactive debugging. However, it might not be
12 easy to devise a simulation tool that accurately simulates the \gls{mTask}
13 system on some levels. The semantics can be simulated but timing and peripheral
14 input/output are more difficult to simulate properly.
15
16 \subsection{Optimization}
17 \paragraph{Multitasking on the client:}
18 True multitasking could be added to the client software. This allows
19 \gls{mTask}-\glspl{Task} to run truly parallel. All \gls{mTask}-\glspl{Task}
20 get slices of execution time and will each have their own interpreter state
21 instead of a single system-wide state which is reset after am \gls{mTask}
22 finishes. This does require separate stacks for each \gls{Task} and therefore
23 increases the system requirements of the client software. However, it could be
24 implemented as a compile-time option and exchanged during the handshake so that
25 the server knows the multithreading capabilities of the client. Multithreading
26 allows \glspl{Task} to be truly interruptible by other \glspl{Task}.
27 Furthermore, this allows for more fine-grained timing control of \glspl{Task}.
28
29 \paragraph{Optimizing the interpreter:}
30 Due to time constraints and focus, hardly any work has been done in the
31 interpreter. The current interpreter is a no nonsense stack machine. A lot of
32 improvements can be done in this part. For example, precomputed \emph{gotos}
33 can improve jumping to the correct part of the code corresponding to the
34 correct instruction. Moreover, the stack currently consists of 16-bit values.
35 All operations work on 16-bit values and this simplifies the interpreter
36 implementation. A memory improvement can be made by converting the stack to
37 8-bit values. This does pose some problems since an equality instruction must
38 work on single-byte booleans \emph{and} two-byte integers. Adding specialized
39 instructions per word size could overcome this problem.
40
41 \subsection{Resources}
42 \paragraph{Resource analysis: }
43 Resource analysis during compilation can be useful to determine if an
44 \gls{mTask}-\gls{Task} is suitable for a specific device. If the device does
45 not contain the correct peripherals --- such as an \gls{LCD} --- then the
46 \gls{mTask}-\gls{Task} should be rejected and feedback to the user must be
47 given. It might even be possible to do this statically on the type level. The
48 current system does not have any of this built-in. Sending a \gls{Task} that
49 uses the \gls{LCD} to a device not containing one will result in the device
50 just skipping the \gls{LCD} related instructions.
51
52 \paragraph{Extended resource analysis: }
53 The previous idea could be extended to the analysis of stack size and possibly
54 communication bandwidth. With this functionality ever more reliable fail-over
55 systems can be designed. When the system knows precise bounds it can allocate
56 more \glspl{Task} on a device whilst staying within safe memory bounds. The
57 resource allocation can be done at runtime within the backend itself or a
58 general backend can be devised that can calculate the resources needed for a
59 given \gls{mTask}. A specific \gls{mTask} cannot have multiple views at the
60 same time due to the restrictions of class based shallow embedding. It might
61 even be possible to encode the resource allocation in the type system itself
62 using forms of dependant types.
63
64 \subsection{Functionality}
65 \paragraph{Add more combinators: }
66 More \gls{Task}-combinators --- already existing in the \gls{iTasks}-system ---
67 could be added to the \gls{mTask}-system to allow for more fine-grained control
68 flow between \gls{mTask}-\glspl{Task}. In this way the new system follows the
69 \gls{TOP} paradigm even more and makes programming \gls{mTask}-\glspl{Task} for
70 \gls{TOP}-programmers more seamless. Some of the combinators require previously
71 mentioned extension such as the parallel combinator. Others might be achieved
72 using simple syntactic transformations.
73
74 \paragraph{Launch \glspl{Task} from a \gls{Task}:}
75 Currently the \gls{C}-view allows \glspl{Task} to launch other \glspl{Task}. In
76 the current system this type of logic has to take place on the server side.
77 Adding this functionality to the bytecode-view allows greater flexibility,
78 easier programming and less communication resources. Adding these semantics
79 requires modifications to the client software and extensions to the
80 communication protocol since relations between \glspl{Task} also need to be
81 encoded and communicated.
82
83 The \gls{SDS} functionality in the current system is bare. There is no easy way
84 of reusing an \gls{SDS} for another \gls{Task} on the same device or on another
85 device. Such functionality can be implemented in a crude way by tying the
86 \glspl{SDS} together in the \gls{iTasks} environment. However, this will result
87 in a slow updating system. Functionality for reusing shares from a device
88 should be added. This requires rethinking the storage because some typedness is
89 lost when the \gls{SDS} is stored after compilation. A possibility would be to
90 use runtime typing with \CI{Dynamic}s or the encoding technique currently used
91 for \CI{BCValue}s. Using \glspl{SDS} for multiple \glspl{Task} within one
92 device is solved when the previous point is implemented.
93
94 Another way of improving on \gls{SDS} handling is to separate \glspl{SDS} from
95 devices. In this implementation, the \gls{SDS} not only needs to know on which
96 device it is, but also which internal device \gls{SDS} id it has. A pro of
97 this technique is that the \gls{SDS} can be shared between \glspl{Task} that
98 are not defined in the same scope because they are separated. A con of this
99 implementation is that the mechanisms for implementing \glspl{SDS} have to be
100 more complex, they have to keep track of the devices containing or sharing an
101 \gls{SDS}. Moreover, when the \gls{SDS} is updated, all attached devices must
102 be updated which requires some extra work.
103
104 \subsection{Robustness}
105 \paragraph{Reconnect with lost devices:}
106 The robustness of the system can be greatly improved. Devices that lose
107 connection are not well supported in the current system. The device will stop
108 functioning and has to be emptied for a reconnect. \Glspl{Task} residing on a
109 device that disconnected should be kept on the server to allow a swift
110 reconnect and restoration of the \glspl{Task}. This holds the same for the
111 client software. The client drops all existing \glspl{Task} on a shutdown
112 request. An extra specialization of the shutdown could be added that drops the
113 connection but keeps the \glspl{Task} in memory. During the downtime the
114 \glspl{Task} can still be executed but publications need to be delayed. If the
115 same server connects to the client the delayed publications can be sent
116 anyways.
117
118 \paragraph{Reverse \gls{Task} sending:}
119 Furthermore, devices could send their current \glspl{Task} back to the
120 server to synchronize it. This allows interchanging servers without
121 interrupting the client. Allowing the client to send \glspl{Task} to the server
122 is something to handle with care because it can easily cause high bandwidth
123 usage.