|
@@ -0,0 +1,623 @@
|
|
1
|
+\documentclass{article}
|
|
2
|
+
|
|
3
|
+\usepackage{rtsched}
|
|
4
|
+\usepackage{url}
|
|
5
|
+
|
|
6
|
+\title{The \texttt{rtsched} package for \LaTeX \\ (version 1.0)}
|
|
7
|
+\author{Giuseppe Lipari}
|
|
8
|
+
|
|
9
|
+\begin{document}
|
|
10
|
+
|
|
11
|
+\maketitle
|
|
12
|
+
|
|
13
|
+\listoffigures
|
|
14
|
+
|
|
15
|
+\section{Introduction}
|
|
16
|
+
|
|
17
|
+In this document, I give an overview of the \texttt{rtsched} \LaTeX
|
|
18
|
+package, which can be used to easily draw chronograms (GANTT charts).
|
|
19
|
+These diagrams are quite common in real-time scheduling research.
|
|
20
|
+
|
|
21
|
+The package depends on keyval, multido and pstricks, all widely
|
|
22
|
+available on any \TeX distribution.
|
|
23
|
+
|
|
24
|
+The drawing capabilities are completely based on the PSTricks: for
|
|
25
|
+this reason, it may not be safe to use \texttt{pdfLaTeX} to compile a
|
|
26
|
+document that uses the \texttt{rtsched} package, due to the fact that
|
|
27
|
+at the time of this writing, PSTricks is not well supported by
|
|
28
|
+pdfLatex. If you want to produce pdf files (for example for making
|
|
29
|
+slides with Beamer), consider using the following compilation chain:
|
|
30
|
+
|
|
31
|
+\begin{verbatim}
|
|
32
|
+latex doc.tex && dvips doc.dvi && ps2pdf doc.ps
|
|
33
|
+\end{verbatim}
|
|
34
|
+
|
|
35
|
+As said, the style works also with Beamer, and it is also possible to
|
|
36
|
+use animations.
|
|
37
|
+
|
|
38
|
+You can find more examples of usage of this style in my lectures,
|
|
39
|
+which can be downloaded at the following address:
|
|
40
|
+\url{http://retis.sssup.it/~lipari/courses/}.
|
|
41
|
+
|
|
42
|
+I prefer to demonstrate the capabilities of the package by a set of
|
|
43
|
+examples. You can just cut and paste the examples and play with them
|
|
44
|
+as you wish.
|
|
45
|
+
|
|
46
|
+\section{Basic commands}
|
|
47
|
+
|
|
48
|
+\subsection{Simple example with two tasks}
|
|
49
|
+
|
|
50
|
+In Figure \ref{fig:ex1} I show a simple example of the Rate Monotonic
|
|
51
|
+schedule of two simple tasks, followed by the code that generated it.
|
|
52
|
+To draw the grid, with the numbers, you have to use the
|
|
53
|
+\texttt{RTGrid} environment:
|
|
54
|
+\begin{verbatim}
|
|
55
|
+\begin{RTGrid}[options]{n}{t}
|
|
56
|
+...
|
|
57
|
+\end{RTGrid}
|
|
58
|
+\end{verbatim}
|
|
59
|
+\noindent where \texttt{n} is the number of horizontal axis (one per
|
|
60
|
+task, in this case), and \texttt{t} is the length of the axis in time
|
|
61
|
+units. This also draws the task labels on the left, and the numbering
|
|
62
|
+on the bottom.
|
|
63
|
+
|
|
64
|
+Every job arrival is depicted with an upward arrow; a deadline is
|
|
65
|
+depicted by a downward arrow (not very visible here, since it concides
|
|
66
|
+with the next arrival, see Figure \ref{fig:ex1c} for deadlines
|
|
67
|
+different from periods). The task execution is depicted by a gray box.
|
|
68
|
+
|
|
69
|
+The arrival of a job and the corresponding deadline can be obtained by
|
|
70
|
+using the following commands:
|
|
71
|
+\begin{verbatim}
|
|
72
|
+\TaskArrival{i}{t}
|
|
73
|
+\TaskArrDeadl{i}{t}{reld}
|
|
74
|
+\end{verbatim}
|
|
75
|
+\noindent where \texttt{i} is the task index (from 1 to \texttt{n}
|
|
76
|
+included), \texttt{t} is the arival time, and \texttt{reld} is the
|
|
77
|
+relative deadline; an absolute deadline will be drawn at \texttt{t +
|
|
78
|
+ reld}.
|
|
79
|
+
|
|
80
|
+In this example there are a lot of repetitions. These can be avoided
|
|
81
|
+if you use the \texttt{multido} macro, as shown in the example of
|
|
82
|
+Figure \ref{fig:ex1a}.
|
|
83
|
+
|
|
84
|
+To draw the execution rectangle, you can use the following command:
|
|
85
|
+\begin{verbatim}
|
|
86
|
+\TaskExecution{i}{t1}{t2}
|
|
87
|
+\TaskExecDelta{i}{t}{delta}
|
|
88
|
+\end{verbatim}
|
|
89
|
+The first one is used to draw an execution rectangle of height 1-unit
|
|
90
|
+for the \texttt{i}-th task from \texttt{t1} to \texttt{t2}. The second
|
|
91
|
+command draws a rectangle from \texttt{t} to \texttt{t+delta}.
|
|
92
|
+
|
|
93
|
+In Figure \ref{fig:ex1b}, you can see how to only draw arrival upward
|
|
94
|
+arrows, and how to specify offsets. Finally, in Figure \ref{fig:ex1c}
|
|
95
|
+you can see an example with 2 tasks with relative deadlines different
|
|
96
|
+from periods (the so-called \emph{constrained deadline tasks}).
|
|
97
|
+
|
|
98
|
+\begin{figure}[h]
|
|
99
|
+ \centering
|
|
100
|
+ % 2 tasks, for 20 units of time
|
|
101
|
+ % we specify the width (10cm is the default
|
|
102
|
+ % value, so we will stop specifying it from now on)
|
|
103
|
+ \begin{RTGrid}[width=10cm]{2}{20}
|
|
104
|
+ %% the first job of task 1 arrives at time 0,
|
|
105
|
+ %% with a relative deadline of 4
|
|
106
|
+ \TaskArrDead{1}{0}{4}
|
|
107
|
+ %% the second job arrives at time 4
|
|
108
|
+ \TaskArrDead{1}{4}{4}
|
|
109
|
+ %% etc
|
|
110
|
+ \TaskArrDead{1}{8}{4}
|
|
111
|
+ \TaskArrDead{1}{12}{4}
|
|
112
|
+ \TaskArrDead{1}{16}{4}
|
|
113
|
+
|
|
114
|
+ %% the task executes in intervals [0,1], [4,5], etc.
|
|
115
|
+ \TaskExecution{1}{0}{1}
|
|
116
|
+ \TaskExecution{1}{4}{5}
|
|
117
|
+ \TaskExecution{1}{8}{9}
|
|
118
|
+ \TaskExecution{1}{12}{13}
|
|
119
|
+ \TaskExecution{1}{16}{17}
|
|
120
|
+
|
|
121
|
+ %% the second task
|
|
122
|
+ \TaskArrDead{2}{0}{4}
|
|
123
|
+ \TaskArrDead{2}{6}{4}
|
|
124
|
+ \TaskArrDead{2}{12}{4}
|
|
125
|
+ \TaskExecution{2}{1}{4}
|
|
126
|
+ \TaskExecution{2}{6}{8}
|
|
127
|
+ \TaskExecution{2}{9}{10}
|
|
128
|
+ \TaskExecution{2}{13}{16}
|
|
129
|
+ \end{RTGrid}
|
|
130
|
+\begin{verbatim}
|
|
131
|
+ % 2 tasks, for 20 units of time
|
|
132
|
+ % we specify the width (10cm is the default
|
|
133
|
+ % value, so we will stop specifying it from now on)
|
|
134
|
+ \begin{RTGrid}[width=10cm]{2}{20}
|
|
135
|
+ %% the first job of task 1 arrives at time 0,
|
|
136
|
+ %% with a relative deadline of 4
|
|
137
|
+ \TaskArrDead{1}{0}{4}
|
|
138
|
+ %% the second job arrives at time 4
|
|
139
|
+ \TaskArrDead{1}{4}{4}
|
|
140
|
+ %% etc
|
|
141
|
+ \TaskArrDead{1}{8}{4}
|
|
142
|
+ \TaskArrDead{1}{12}{4}
|
|
143
|
+ \TaskArrDead{1}{16}{4}
|
|
144
|
+
|
|
145
|
+ %% the task executes in intervals [0,1], [4,5], etc.
|
|
146
|
+ \TaskExecution{1}{0}{1}
|
|
147
|
+ \TaskExecution{1}{4}{5}
|
|
148
|
+ \TaskExecution{1}{8}{9}
|
|
149
|
+ \TaskExecution{1}{12}{13}
|
|
150
|
+ \TaskExecution{1}{16}{17}
|
|
151
|
+
|
|
152
|
+ %% the second task
|
|
153
|
+ \TaskArrDead{2}{0}{4}
|
|
154
|
+ \TaskArrDead{2}{6}{4}
|
|
155
|
+ \TaskArrDead{2}{12}{4}
|
|
156
|
+ \TaskExecution{2}{1}{4}
|
|
157
|
+ \TaskExecution{2}{6}{8}
|
|
158
|
+ \TaskExecution{2}{9}{10}
|
|
159
|
+ \TaskExecution{2}{13}{16}
|
|
160
|
+ \end{RTGrid}
|
|
161
|
+\end{verbatim}
|
|
162
|
+ \caption{Two tasks, with deadline equal to period, RM scheduling}
|
|
163
|
+ \label{fig:ex1}
|
|
164
|
+\end{figure}
|
|
165
|
+
|
|
166
|
+\begin{figure}[h]
|
|
167
|
+ \centering
|
|
168
|
+ \begin{RTGrid}{2}{20}
|
|
169
|
+ \multido{\n=0+4}{5}{ % 5 instances of period 4
|
|
170
|
+ \TaskArrDead{1}{\n}{4} % draw the arrival and deadline
|
|
171
|
+ \TaskExecDelta{1}{\n}{1} % draw execution (highest priority),
|
|
172
|
+ % from \n to \n+1
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ \multido{\n=0+6}{3}{ % 3 instances of period 6
|
|
176
|
+ \TaskArrDead{2}{\n}{6} % draw the arrival and deadline
|
|
177
|
+ }
|
|
178
|
+ % no simple formula for lowest priority, sorry!
|
|
179
|
+ \TaskExecution{2}{1}{4}
|
|
180
|
+ \TaskExecution{2}{6}{8}
|
|
181
|
+ \TaskExecution{2}{9}{10}
|
|
182
|
+ \TaskExecution{2}{13}{16}
|
|
183
|
+ \end{RTGrid}
|
|
184
|
+
|
|
185
|
+\begin{verbatim}
|
|
186
|
+ \begin{RTGrid}{2}{20}
|
|
187
|
+ \multido{\n=0+4}{5}{ % 4 instances of period 4
|
|
188
|
+ \TaskArrDead{1}{\n}{4} % draw the arrival and deadline
|
|
189
|
+ \TaskExecDelta{1}{\n}{1} % draw execution (highest priority),
|
|
190
|
+ % from \n to \n+1
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ \multido{\n=0+6}{3}{ % 3 instances of period 6
|
|
194
|
+ \TaskArrDead{2}{\n}{6} % draw the arrival and deadline
|
|
195
|
+ }
|
|
196
|
+ % no simple formula for lowest priority, sorry!
|
|
197
|
+ \TaskExecution{2}{1}{4}
|
|
198
|
+ \TaskExecution{2}{6}{8}
|
|
199
|
+ \TaskExecution{2}{9}{10}
|
|
200
|
+ \TaskExecution{2}{13}{16}
|
|
201
|
+ \end{RTGrid}
|
|
202
|
+\end{verbatim}
|
|
203
|
+ \caption{Using multido to avoid repetitions}
|
|
204
|
+ \label{fig:ex1a}
|
|
205
|
+\end{figure}
|
|
206
|
+
|
|
207
|
+\begin{figure}[h]
|
|
208
|
+ \centering
|
|
209
|
+ \begin{RTGrid}{3}{14}
|
|
210
|
+ \multido{\n=0+3}{4}{ % 4 instances of period 3, starting from 0
|
|
211
|
+ \TaskArrival{1}{\n} % draw only the arrival
|
|
212
|
+ \TaskExecDelta{1}{\n}{1} % draw execution (highest priority),
|
|
213
|
+ % from \n to \n+1
|
|
214
|
+ }
|
|
215
|
+
|
|
216
|
+ \multido{\n=3+4}{3}{ % 3 instances of period 4, starting from 3
|
|
217
|
+ \TaskArrival{2}{\n} % draw only the arrival
|
|
218
|
+ }
|
|
219
|
+ \TaskExecDelta{2}{4}{1}
|
|
220
|
+ \TaskExecDelta{2}{7}{1}
|
|
221
|
+ \TaskExecDelta{2}{11}{1}
|
|
222
|
+
|
|
223
|
+ \multido{\n=1+5}{3}{ % 3 instances of period 5, starting from 1
|
|
224
|
+ \TaskArrival{3}{\n} % draw only the arrival
|
|
225
|
+ }
|
|
226
|
+ \TaskExecDelta{3}{1}{1}
|
|
227
|
+ \TaskExecDelta{3}{8}{1}
|
|
228
|
+ \TaskExecDelta{3}{12}{1}
|
|
229
|
+ \end{RTGrid}
|
|
230
|
+
|
|
231
|
+\begin{verbatim}
|
|
232
|
+ \begin{RTGrid}{3}{14}
|
|
233
|
+ \multido{\n=0+3}{4}{ % 4 instances of period 3
|
|
234
|
+ \TaskArrival{1}{\n} % draw only the arrival
|
|
235
|
+ \TaskExecDelta{1}{\n}{1}} % draw execution (highest priority),
|
|
236
|
+ % from \n to \n+1
|
|
237
|
+
|
|
238
|
+ \multido{\n=3+4}{3}{ % 3 instances of period 4, starting from 3
|
|
239
|
+ \TaskArrival{2}{\n}} % draw only the arrival
|
|
240
|
+
|
|
241
|
+ \TaskExecDelta{2}{4}{1}
|
|
242
|
+ \TaskExecDelta{2}{7}{1}
|
|
243
|
+ \TaskExecDelta{2}{11}{1}
|
|
244
|
+
|
|
245
|
+ \multido{\n=1+5}{3}{ % 3 instances of period 5, starting from 1
|
|
246
|
+ \TaskArrival{3}{\n}} % draw only the arrival
|
|
247
|
+
|
|
248
|
+ \TaskExecDelta{3}{1}{1}
|
|
249
|
+ \TaskExecDelta{3}{8}{1}
|
|
250
|
+ \TaskExecDelta{3}{12}{1}
|
|
251
|
+ \end{RTGrid}
|
|
252
|
+\end{verbatim}
|
|
253
|
+ \caption{Three tasks with offsets, and only arrivals with no deadlines}
|
|
254
|
+ \label{fig:ex1b}
|
|
255
|
+\end{figure}
|
|
256
|
+
|
|
257
|
+\begin{figure}[h]
|
|
258
|
+ \centering
|
|
259
|
+ \begin{RTGrid}[width=8cm]{2}{15}
|
|
260
|
+ \multido{\n=0+6}{3}{
|
|
261
|
+ \TaskArrDead{1}{\n}{3}}
|
|
262
|
+ \multido{\n=2+8}{2}{
|
|
263
|
+ \TaskArrDead{2}{\n}{5}}
|
|
264
|
+ \end{RTGrid}
|
|
265
|
+\begin{verbatim}
|
|
266
|
+ \multido{\n=0+6}{3}{
|
|
267
|
+ \TaskArrDead{1}{\n}{3}}
|
|
268
|
+ \multido{\n=2+8}{2}{
|
|
269
|
+ \TaskArrDead{2}{\n}{5}}
|
|
270
|
+\end{verbatim}
|
|
271
|
+ \caption{Deadlines less than periods}
|
|
272
|
+ \label{fig:ex1c}
|
|
273
|
+\end{figure}
|
|
274
|
+
|
|
275
|
+It is also possible to visualise preempted tasks with a hatched fill
|
|
276
|
+style. An example is in Figure~\ref{fig:resp-time} that uses command
|
|
277
|
+\texttt{TaskRespTime}.
|
|
278
|
+
|
|
279
|
+\begin{figure}
|
|
280
|
+ \centering
|
|
281
|
+ \begin{RTGrid}{2}{20}
|
|
282
|
+ \multido{\n=0+4}{5}{ % 5 instances of period 4
|
|
283
|
+ \TaskArrDead{1}{\n}{4} % draw the arrival and deadline
|
|
284
|
+ \TaskExecDelta{1}{\n}{1} % draw execution (highest priority),
|
|
285
|
+ % from \n to \n+1
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+ \multido{\n=0+6}{3}{ % 3 instances of period 6
|
|
289
|
+ \TaskArrDead{2}{\n}{6} % draw the arrival and deadline
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ \TaskRespTime{2}{0}{4}
|
|
293
|
+ \TaskExecution{2}{1}{4}
|
|
294
|
+ \TaskRespTime{2}{6}{4}
|
|
295
|
+ \TaskExecution{2}{6}{8}
|
|
296
|
+ \TaskExecution{2}{9}{10}
|
|
297
|
+ \TaskRespTime{2}{12}{4}
|
|
298
|
+ \TaskExecution{2}{13}{16}
|
|
299
|
+ \end{RTGrid}
|
|
300
|
+\begin{verbatim}
|
|
301
|
+ \begin{RTGrid}{2}{20}
|
|
302
|
+ \multido{\n=0+4}{5}{
|
|
303
|
+ \TaskArrDead{1}{\n}{4}
|
|
304
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
305
|
+ \multido{\n=0+6}{3}{
|
|
306
|
+ \TaskArrDead{2}{\n}{6}}
|
|
307
|
+
|
|
308
|
+ \TaskRespTime{2}{0}{4} % draws the hatched rectangle in [0,4]
|
|
309
|
+ \TaskExecution{2}{1}{4} % draws execution (over the previous rectangle)
|
|
310
|
+ \TaskRespTime{2}{6}{4} % draws the hatched rectangle in [6,10]
|
|
311
|
+ \TaskExecution{2}{6}{8} % draws execution
|
|
312
|
+ \TaskExecution{2}{9}{10} % draws execution
|
|
313
|
+ \TaskRespTime{2}{12}{4} % draws the hatched rectangle in [12,16]
|
|
314
|
+ \TaskExecution{2}{13}{16} % draws execution
|
|
315
|
+ \end{RTGrid}
|
|
316
|
+\end{verbatim}
|
|
317
|
+ \caption{Example with TaskRespTime}
|
|
318
|
+ \label{fig:resp-time}
|
|
319
|
+\end{figure}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+\subsection{Controlling visualization}
|
|
323
|
+
|
|
324
|
+It is possible to specify many options in the \texttt{RTGrid}
|
|
325
|
+environment. Maybe you don't like the grid: then, you can decide to
|
|
326
|
+not visualise it as in Figure \ref{fig:ex2}, where we also removed the
|
|
327
|
+task symbols.
|
|
328
|
+\begin{figure}[h]
|
|
329
|
+ \centering
|
|
330
|
+ %% no grid and no symbols
|
|
331
|
+ \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
|
|
332
|
+ \multido{\n=0+4}{5}{
|
|
333
|
+ \TaskArrDead{1}{\n}{4}
|
|
334
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
335
|
+ \multido{\n=0+6}{3}{
|
|
336
|
+ \TaskArrDead{2}{\n}{6}}
|
|
337
|
+ \TaskExecution{2}{1}{4}
|
|
338
|
+ \TaskExecution{2}{6}{8}
|
|
339
|
+ \TaskExecution{2}{9}{10}
|
|
340
|
+ \TaskExecution{2}{13}{16}
|
|
341
|
+ \end{RTGrid}
|
|
342
|
+\begin{verbatim}
|
|
343
|
+ %% no grid and no symbols
|
|
344
|
+ \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
|
|
345
|
+ \multido{\n=0+4}{5}{
|
|
346
|
+ \TaskArrDead{1}{\n}{4}
|
|
347
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
348
|
+ \multido{\n=0+6}{3}{
|
|
349
|
+ \TaskArrDead{2}{\n}{6}}
|
|
350
|
+ \TaskExecution{2}{1}{4}
|
|
351
|
+ \TaskExecution{2}{6}{8}
|
|
352
|
+ \TaskExecution{2}{9}{10}
|
|
353
|
+ \TaskExecution{2}{13}{16}
|
|
354
|
+ \end{RTGrid}
|
|
355
|
+\end{verbatim}
|
|
356
|
+ \caption{Removing visualization of the grid and of the task names}
|
|
357
|
+ \label{fig:ex2}
|
|
358
|
+\end{figure}
|
|
359
|
+
|
|
360
|
+The next figure \ref{fig:ex2a} uses different task symbols, does not
|
|
361
|
+show the numbers on the time line, and the color of the boxes that
|
|
362
|
+denote the execution of the second instance of the second task are
|
|
363
|
+changed to red. Also, I am changing the width, so the figure looks
|
|
364
|
+smaller.
|
|
365
|
+
|
|
366
|
+\begin{figure}[h]
|
|
367
|
+ \centering
|
|
368
|
+ %% specify 1) no numbers on the time line, 2) a different symbol, 3)
|
|
369
|
+ %% a different size of the symbol (default is 8pt).
|
|
370
|
+ %% Notice that you should not use the math mode in the
|
|
371
|
+ %% specification of the symbol, as the symbol is already used in a
|
|
372
|
+ %% math environment inside the macro
|
|
373
|
+ \begin{RTGrid}[width=8cm,symbol=\gamma,nonumbers=1,labelsize=11pt]{2}{20}
|
|
374
|
+ \multido{\n=0+4}{5}{
|
|
375
|
+ \TaskArrDead{1}{\n}{4}
|
|
376
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
377
|
+ \multido{\n=0+6}{3}{
|
|
378
|
+ \TaskArrDead{2}{\n}{6}
|
|
379
|
+ }
|
|
380
|
+ %% here, the border changes to cyan, and the fill to white
|
|
381
|
+ \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
|
|
382
|
+ %% the next two boxes are filled with red instead of gray
|
|
383
|
+ \TaskExecution[color=red]{2}{6}{8}
|
|
384
|
+ \TaskExecution[color=red]{2}{9}{10}
|
|
385
|
+ \TaskExecution{2}{13}{16}
|
|
386
|
+ \end{RTGrid}
|
|
387
|
+
|
|
388
|
+\begin{verbatim}
|
|
389
|
+ %% specify 1) no numbers on the time line, 2) a different symbol, 3)
|
|
390
|
+ %% a different size of the symbol (default is 8pt).
|
|
391
|
+ %% Notice that you should not use the math mode in the
|
|
392
|
+ %% specification of the symbol, as the symbol is already used in a
|
|
393
|
+ %% math environment inside the macro
|
|
394
|
+ \begin{RTGrid}[symbol=\gamma,nonumbers=1,labelsize=11pt]{2}{20}
|
|
395
|
+ \multido{\n=0+4}{5}{
|
|
396
|
+ \TaskArrDead{1}{\n}{4}
|
|
397
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
398
|
+ \multido{\n=0+6}{3}{
|
|
399
|
+ \TaskArrDead{2}{\n}{6}
|
|
400
|
+ }
|
|
401
|
+ %% here, the border changes to cyan, and the fill to white
|
|
402
|
+ \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
|
|
403
|
+ %% the next two boxes are filled with red instead of gray
|
|
404
|
+ \TaskExecution[color=red]{2}{6}{8}
|
|
405
|
+ \TaskExecution[color=red]{2}{9}{10}
|
|
406
|
+ \TaskExecution{2}{13}{16}
|
|
407
|
+ \end{RTGrid}
|
|
408
|
+\end{verbatim}
|
|
409
|
+ \caption{Different symbols (with size 11pt), no numbers, a different
|
|
410
|
+ task color}
|
|
411
|
+ \label{fig:ex2a}
|
|
412
|
+\end{figure}
|
|
413
|
+
|
|
414
|
+Do you want to specify an arbitrary symbol at a certain row?
|
|
415
|
+No problem! See the example in Figure \ref{fig:ex2b}. Here we use the command:
|
|
416
|
+\begin{verbatim}
|
|
417
|
+\RowLabel{i}{label}
|
|
418
|
+\end{verbatim}
|
|
419
|
+which writes the \texttt{label} at the specified row (index 1 stays at
|
|
420
|
+the top). Here we show also how to specify an arbitrary starting
|
|
421
|
+number in the time line, using the \texttt{numoffset=12} option.
|
|
422
|
+
|
|
423
|
+\begin{figure}[h]
|
|
424
|
+ \centering
|
|
425
|
+ %% specify 1) no numbers on the time line, 2) number starting from
|
|
426
|
+ %% 12
|
|
427
|
+ \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
|
|
428
|
+ %% the symbol for the first row
|
|
429
|
+ \RowLabel{1}{Server}
|
|
430
|
+ %% the symbol for the second row
|
|
431
|
+ \RowLabel{2}{$\Pi_2$}
|
|
432
|
+ \multido{\n=0+4}{5}{
|
|
433
|
+ \TaskArrDead{1}{\n}{4}
|
|
434
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
435
|
+ \multido{\n=0+6}{3}{
|
|
436
|
+ \TaskArrDead{2}{\n}{6}
|
|
437
|
+ }
|
|
438
|
+ \TaskExecution{2}{1}{4}
|
|
439
|
+ \TaskExecution{2}{6}{8}
|
|
440
|
+ \TaskExecution{2}{9}{10}
|
|
441
|
+ \TaskExecution{2}{13}{16}
|
|
442
|
+ \end{RTGrid}
|
|
443
|
+\begin{verbatim}
|
|
444
|
+ %% specify 1) no numbers on the time line, 2) number starting from 12
|
|
445
|
+ \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
|
|
446
|
+ %% the symbol for the first row
|
|
447
|
+ \RowLabel{1}{Server}
|
|
448
|
+ %% the symbol for the second row
|
|
449
|
+ \RowLabel{2}{$\Pi_2$}
|
|
450
|
+ \multido{\n=0+4}{5}{
|
|
451
|
+ \TaskArrDead{1}{\n}{4}
|
|
452
|
+ \TaskExecDelta{1}{\n}{1}}
|
|
453
|
+ \multido{\n=0+6}{3}{
|
|
454
|
+ \TaskArrDead{2}{\n}{6}
|
|
455
|
+ }
|
|
456
|
+ \TaskExecution{2}{1}{4}
|
|
457
|
+ \TaskExecution{2}{6}{8}
|
|
458
|
+ \TaskExecution{2}{9}{10}
|
|
459
|
+ \TaskExecution{2}{13}{16}
|
|
460
|
+ \end{RTGrid}
|
|
461
|
+\end{verbatim}
|
|
462
|
+ \caption{Arbitrary symbols with an appropriate offset, no grid, numbering starting from 12}
|
|
463
|
+ \label{fig:ex2b}
|
|
464
|
+\end{figure}
|
|
465
|
+
|
|
466
|
+% In the last example (Figure \ref{fig:ex2c}), we show an empty grid in
|
|
467
|
+% which we specify width and height.
|
|
468
|
+
|
|
469
|
+% \begin{figure}[h]
|
|
470
|
+% \centering
|
|
471
|
+% %% 3 tasks, 10 units of time
|
|
472
|
+% \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
|
|
473
|
+
|
|
474
|
+% \end{RTGrid}
|
|
475
|
+
|
|
476
|
+% \begin{verbatim}
|
|
477
|
+% %% 3 tasks, 10 units of time
|
|
478
|
+% \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
|
|
479
|
+
|
|
480
|
+% \end{RTGrid}
|
|
481
|
+% \end{verbatim}
|
|
482
|
+% \caption{Empty grid with strange width and height}
|
|
483
|
+% \label{fig:ex2c}
|
|
484
|
+% \end{figure}
|
|
485
|
+
|
|
486
|
+\subsection{Highlighting and labeling objects}
|
|
487
|
+
|
|
488
|
+Sometimes it may be important to say that one task has caused the
|
|
489
|
+activation of another task. You can use the following command, as
|
|
490
|
+shown in Figure \ref{fig:ex3a}:
|
|
491
|
+\begin{verbatim}
|
|
492
|
+\Activation{i}{t1}{j}{t2}
|
|
493
|
+\end{verbatim}
|
|
494
|
+which draws an arrow from the baseline of task \texttt{i} at time
|
|
495
|
+\texttt{t1} to the baseline of task \texttt{j} at time \texttt{t2}.
|
|
496
|
+Also, you can put an arbitrary label inside a shadow box with the
|
|
497
|
+following command:
|
|
498
|
+\begin{verbatim}
|
|
499
|
+\Label{y}{x}{label}
|
|
500
|
+\end{verbatim}
|
|
501
|
+which draws a boxed label at position \texttt{x,y} in the grid.
|
|
502
|
+
|
|
503
|
+Finally, it is possible to draw a rectangular box with rounded corners
|
|
504
|
+to highlight a portion of the schedule with \texttt{RTBox}:
|
|
505
|
+\begin{verbatim}
|
|
506
|
+\RTBox{t1}{t2}
|
|
507
|
+\end{verbatim}
|
|
508
|
+
|
|
509
|
+\begin{figure}[h]
|
|
510
|
+ \centering
|
|
511
|
+ \begin{RTGrid}{2}{20}
|
|
512
|
+ \RTBox{12}{16}
|
|
513
|
+ \multido{\n=0+6}{4}{
|
|
514
|
+ \TaskArrival{1}{\n}
|
|
515
|
+ \TaskExecDelta{1}{\n}{2}}
|
|
516
|
+ \TaskArrival{2}{10}
|
|
517
|
+ \TaskExecDelta{2}{10}{3}
|
|
518
|
+ \Activation{1}{8}{2}{10}
|
|
519
|
+ \Label{6}{7}{$\delta$}
|
|
520
|
+ \end{RTGrid}
|
|
521
|
+\begin{verbatim}
|
|
522
|
+ \begin{RTGrid}{2}{20}
|
|
523
|
+ \RTBox{12}{16}
|
|
524
|
+ \multido{\n=0+6}{4}{
|
|
525
|
+ \TaskArrival{1}{\n}
|
|
526
|
+ \TaskExecDelta{1}{\n}{2}}
|
|
527
|
+ \TaskArrival{2}{10}
|
|
528
|
+ \TaskExecDelta{2}{10}{3}
|
|
529
|
+ \Activation{1}{8}{2}{10}
|
|
530
|
+ \Label{6}{7}{$\delta$}
|
|
531
|
+ \end{RTGrid}
|
|
532
|
+\end{verbatim}
|
|
533
|
+ \caption{Activation (from one task to another one), and an arbitrary label}
|
|
534
|
+ \label{fig:ex3a}
|
|
535
|
+\end{figure}
|
|
536
|
+
|
|
537
|
+Notice that the order with which the objects are drawn is exactly the
|
|
538
|
+same as the order in which they are specified in the code. For
|
|
539
|
+example, in Figure \ref{fig:ex3a}, the executions of all the tasks are
|
|
540
|
+drawn on top of the box. You can try to move the \texttt{RTBox}
|
|
541
|
+command at the end to see what happens.
|
|
542
|
+
|
|
543
|
+\subsection{Priority Inheritance}
|
|
544
|
+
|
|
545
|
+An example of task locking/unlocking and the use of the Priority
|
|
546
|
+Inheritance Protocol is shown in Figure \ref{fig:pi}. Here, task
|
|
547
|
+$\tau_3$ locks resource $S$ at time $t=2$. This is obtained by using
|
|
548
|
+command:
|
|
549
|
+\begin{verbatim}
|
|
550
|
+\TaskLock{3}{2}{S}
|
|
551
|
+\end{verbatim}
|
|
552
|
+Unlock is similarly obtained by using command:
|
|
553
|
+\begin{verbatim}
|
|
554
|
+\TaskUnlock{3}{7}{S}
|
|
555
|
+\end{verbatim}
|
|
556
|
+
|
|
557
|
+Task $\tau_1$ tries to lock the same resource at time $t=5$. The
|
|
558
|
+priority of $\tau_1$ is then inherited by $\tau_3$: the inheritance
|
|
559
|
+rule is depicted by using a dashed tick arrow from the baseline of
|
|
560
|
+$\tau_1$ to $\tau_3$, using command:
|
|
561
|
+\begin{verbatim}
|
|
562
|
+\Inherit{1}{3}{4}
|
|
563
|
+\end{verbatim}
|
|
564
|
+The fact that $\tau_3$ is executing inside a critical section is
|
|
565
|
+denoted by putting a label inside the execution block, using the
|
|
566
|
+following command:
|
|
567
|
+\begin{verbatim}
|
|
568
|
+\TaskExecution[color=white,execlabel=S]{3}{4}{5}
|
|
569
|
+\end{verbatim}
|
|
570
|
+
|
|
571
|
+\begin{figure}
|
|
572
|
+ \centering
|
|
573
|
+ \begin{RTGrid}[width=12cm]{3}{25}
|
|
574
|
+ \TaskArrDead{3}{0}{20}
|
|
575
|
+ \TaskExecution{3}{0}{2}
|
|
576
|
+ \TaskLock{3}{2}{S}
|
|
577
|
+ \TaskExecution[color=white,execlabel=S]{3}{2}{3}
|
|
578
|
+ \TaskArrDead{1}{3}{9}
|
|
579
|
+ \TaskExecution{1}{3}{4}
|
|
580
|
+ \TaskLock{1}{4}{S}
|
|
581
|
+ \Inherit{1}{3}{4}
|
|
582
|
+ \TaskExecution[color=white,execlabel=S]{3}{4}{5}
|
|
583
|
+ \TaskArrDead{2}{5}{12}
|
|
584
|
+ \TaskExecution[color=white,execlabel=S]{3}{5}{7}
|
|
585
|
+ \TaskUnlock{3}{7}{S}
|
|
586
|
+ \TaskExecution[color=white,execlabel=S]{1}{7}{9}
|
|
587
|
+ \TaskUnlock{1}{9}{S}
|
|
588
|
+ \TaskExecution{1}{9}{10}
|
|
589
|
+ \TaskExecution{2}{10}{15}
|
|
590
|
+ \TaskExecution{3}{15}{17}
|
|
591
|
+ \end{RTGrid}
|
|
592
|
+ \caption{Task blocking on resources: the Priority Inheritance Protocol}
|
|
593
|
+ \label{fig:pi}
|
|
594
|
+\begin{verbatim}
|
|
595
|
+ \begin{RTGrid}[width=12cm]{3}{25}
|
|
596
|
+ \TaskArrDead{3}{0}{20}
|
|
597
|
+ \TaskExecution{3}{0}{2}
|
|
598
|
+ \TaskLock{3}{2}{S}
|
|
599
|
+ \TaskExecution[color=white,execlabel=S]{3}{2}{3}
|
|
600
|
+ \TaskArrDead{1}{3}{9}
|
|
601
|
+ \TaskExecution{1}{3}{4}
|
|
602
|
+ \TaskLock{1}{4}{S}
|
|
603
|
+ \Inherit{1}{3}{4}
|
|
604
|
+ \TaskExecution[color=white,execlabel=S]{3}{4}{5}
|
|
605
|
+ \TaskArrDead{2}{5}{12}
|
|
606
|
+ \TaskExecution[color=white,execlabel=S]{3}{5}{7}
|
|
607
|
+ \TaskUnlock{3}{7}{S}
|
|
608
|
+ \TaskExecution[color=white,execlabel=S]{1}{7}{9}
|
|
609
|
+ \TaskUnlock{1}{9}{S}
|
|
610
|
+ \TaskExecution{1}{9}{10}
|
|
611
|
+ \TaskExecution{2}{10}{15}
|
|
612
|
+ \TaskExecution{3}{15}{17}
|
|
613
|
+ \end{RTGrid}
|
|
614
|
+\end{verbatim}
|
|
615
|
+ \caption{Priority Inheritance example}
|
|
616
|
+ \label{fig:ex4}
|
|
617
|
+\end{figure}
|
|
618
|
+
|
|
619
|
+\end{document}
|
|
620
|
+%%% Local Variables:
|
|
621
|
+%%% mode: latex
|
|
622
|
+%%% TeX-master: t
|
|
623
|
+%%% End:
|