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

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