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