Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rtsched-doc.tex 24KB

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