Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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
  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, especially to distinguish it from preemption. In that case, you can use the following command :
  282. \begin{verbatim}
  283. \TaskEnd{i}{t}
  284. \end{verbatim}
  285. 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}.
  286. \subsection{Controlling visualization}
  287. It is possible to specify many options in the \texttt{RTGrid}
  288. environment. Maybe you don't like the grid: then, you can decide to
  289. not visualise it as in Figure \ref{fig:ex2}, where we also removed the
  290. task symbols.
  291. \begin{figure}[!htbp]
  292. \centering
  293. %% no grid and no symbols
  294. \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
  295. \TaskNArrDead{1}{0}{4}{4}{5}
  296. \TaskNExecDelta{1}{0}{1}{4}{5}
  297. \TaskNArrDead{2}{0}{6}{6}{3}
  298. \TaskExecution{2}{1}{4}
  299. \TaskExecution{2}{6}{8}
  300. \TaskExecution{2}{9}{10}
  301. \TaskExecution{2}{13}{16}
  302. \end{RTGrid}
  303. \begin{verbatim}
  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. \end{verbatim}
  315. \caption{Removing visualization of the grid and of the task names}
  316. \label{fig:ex2}
  317. \end{figure}
  318. The next figure \ref{fig:ex2a} uses different task symbols, does not
  319. show the numbers on the time line, and the color of the boxes that
  320. denote the execution of the second instance of the second task are
  321. changed to red. Also, I am changing the width, so the figure looks
  322. smaller. Notice that you can directly specify colors using the TikZ
  323. way (color!percentage for example).
  324. \begin{figure}[!htbp]
  325. \centering
  326. %% specify 1) no numbers on the time line, 2) a different symbol, 3)
  327. %% a different size of the symbol using latex size commands (default is \normalsize).
  328. %% Notice that you should not use the math mode in the
  329. %% specification of the symbol, as the symbol is already used in a
  330. %% math environment inside the macro
  331. \begin{RTGrid}[width=8cm,symbol=\gamma,nonumbers=1,labelsize=\small]{2}{20}
  332. \TaskNArrDead{1}{0}{4}{4}{5}
  333. \TaskNExecDelta{1}{0}{1}{4}{5}
  334. \TaskNArrDead{2}{0}{6}{6}{3}
  335. %% here, the border changes to cyan, and the fill to white
  336. \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
  337. %% the next two boxes are filled with red instead of gray
  338. \TaskExecution[color=red]{2}{6}{8}
  339. \TaskExecution[color=red!50]{2}{9}{10}
  340. \TaskExecution{2}{13}{16}
  341. \end{RTGrid}
  342. \begin{verbatim}
  343. %% specify 1) no numbers on the time line, 2) a different symbol, 3)
  344. %% a different size of the symbol (default is \normalsize).
  345. %% Notice that you should not use the math mode in the
  346. %% specification of the symbol, as the symbol is already used in a
  347. %% math environment inside the macro
  348. \begin{RTGrid}[symbol=\gamma,nonumbers=1,labelsize=\Large]{2}{20}
  349. \TaskNArrDead{1}{0}{4}{4}{5}
  350. \TaskNExecDelta{1}{0}{1}{4}{5}
  351. \TaskNArrDead{2}{0}{6}{6}{3}
  352. %% here, the border changes to cyan, and the fill to white
  353. \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
  354. %% the next two boxes are filled with red instead of gray
  355. \TaskExecution[color=red]{2}{6}{8}
  356. \TaskExecution[color=red]{2}{9}{10}
  357. \TaskExecution{2}{13}{16}
  358. \end{RTGrid}
  359. \end{verbatim}
  360. \caption{Different symbols (with \textbackslash Large size), no numbers, a different
  361. task color}
  362. \label{fig:ex2a}
  363. \end{figure}
  364. Do you want to specify an arbitrary symbol at a certain row?
  365. No problem! See the example in Figure \ref{fig:ex2b}. Here we use the command:
  366. \begin{verbatim}
  367. \RowLabel{i}{label}
  368. \end{verbatim}
  369. which writes the \texttt{label} at the specified row (index 1 stays at
  370. the top). Here we show also how to specify an arbitrary starting
  371. number in the time line, using the \texttt{numoffset=12} option.
  372. \begin{figure}[!htbp]
  373. \centering
  374. %% specify 1) no numbers on the time line, 2) number starting from
  375. %% 12
  376. \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
  377. %% the symbol for the first row
  378. \RowLabel{1}{Server}
  379. %% the symbol for the second row
  380. \RowLabel{2}{$\Pi_2$}
  381. \TaskNArrDead{1}{0}{4}{4}{5}
  382. \TaskNExecDelta{1}{0}{1}{4}{5}
  383. \TaskNArrDead{2}{0}{6}{6}{3}
  384. \TaskExecution{2}{1}{4}
  385. \TaskExecution{2}{6}{8}
  386. \TaskExecution{2}{9}{10}
  387. \TaskExecution{2}{13}{16}
  388. \end{RTGrid}
  389. \begin{verbatim}
  390. %% specify 1) no numbers on the time line, 2) number starting from 12
  391. \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
  392. %% the symbol for the first row
  393. \RowLabel{1}{Server}
  394. %% the symbol for the second row
  395. \RowLabel{2}{$\Pi_2$}
  396. \TaskNArrDead{1}{0}{4}{4}{5}
  397. \TaskNExecDelta{1}{0}{1}{4}{5}
  398. \TaskNArrDead{2}{0}{6}{6}{3}
  399. \TaskExecution{2}{1}{4}
  400. \TaskExecution{2}{6}{8}
  401. \TaskExecution{2}{9}{10}
  402. \TaskExecution{2}{13}{16}
  403. \end{RTGrid}
  404. \end{verbatim}
  405. \caption{Arbitrary symbols with an appropriate offset, no grid, numbering starting from 12}
  406. \label{fig:ex2b}
  407. \end{figure}
  408. % In the last example (Figure \ref{fig:ex2c}), we show an empty grid in
  409. % which we specify width and height.
  410. % \begin{figure}[!htbp]
  411. % \centering
  412. % %% 3 tasks, 10 units of time
  413. % \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
  414. % \end{RTGrid}
  415. % \begin{verbatim}
  416. % %% 3 tasks, 10 units of time
  417. % \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
  418. % \end{RTGrid}
  419. % \end{verbatim}
  420. % \caption{Empty grid with strange width and height}
  421. % \label{fig:ex2c}
  422. % \end{figure}
  423. \subsection{Highlighting and labeling objects}
  424. Sometimes it may be important to say that one task has caused the
  425. activation of another task. You can use the following command, as
  426. shown in Figure \ref{fig:ex3a}:
  427. \begin{verbatim}
  428. \Activation{i}{t1}{j}{t2}
  429. \end{verbatim}
  430. which draws an arrow from the baseline of task \texttt{i} at time
  431. \texttt{t1} to the baseline of task \texttt{j} at time \texttt{t2}.
  432. Also, you can put an arbitrary label inside a shadow box with the
  433. following command:
  434. \begin{verbatim}
  435. \Label{y}{x}{label}
  436. \end{verbatim}
  437. which draws a boxed label at position \texttt{x,y} in the grid.
  438. Finally, it is possible to draw a rectangular box with rounded corners
  439. to highlight a portion of the schedule with \texttt{RTBox}:
  440. \begin{verbatim}
  441. \RTBox{t1}{t2}
  442. \end{verbatim}
  443. \begin{figure}[!htbp]
  444. \centering
  445. \begin{RTGrid}{2}{20}
  446. \RTBox{12}{16}
  447. \TaskArrival{1}{0}{6}{4}
  448. \TaskExecDelta{1}{0}{2}{6}{4}
  449. \TaskArrival{2}{10}
  450. \TaskExecDelta[exeheight=1.5]{2}{10}{3}
  451. \Activation{1}{8}{2}{10}
  452. \Label{6}{7}{$\delta$}
  453. \end{RTGrid}
  454. \begin{verbatim}
  455. \begin{RTGrid}{2}{20}
  456. \RTBox{12}{16}
  457. \TaskArrival{1}{0}{6}{4}
  458. \TaskExecDelta{1}{0}{2}{6}{4}
  459. \TaskArrival{2}{10}
  460. \TaskExecDelta[exeheight=1.5]{2}{10}{3}
  461. \Activation{1}{8}{2}{10}
  462. \Label{6}{7}{$\delta$}
  463. \end{RTGrid}
  464. \end{verbatim}
  465. \caption{Activation (from one task to another one), and an arbitrary label}
  466. \label{fig:ex3a}
  467. \end{figure}
  468. Notice that the order with which the objects are drawn is exactly the
  469. same as the order in which they are specified in the code, excepted
  470. for horizontal axes, arrivals, deadlines and end of job execution that are always drawn on the foreground.
  471. For example, in Figure \ref{fig:ex3a}, the executions of all the tasks are
  472. drawn on top of the box. You can try to move the \texttt{RTBox}
  473. command at the end to see what happens.
  474. \subsection{Priority Inheritance}
  475. An example of task locking/unlocking and the use of the Priority
  476. Inheritance Protocol is shown in Figure \ref{fig:pi}. Here, task
  477. $\tau_3$ locks resource $S$ at time $t=2$. This is obtained by using
  478. command:
  479. \begin{verbatim}
  480. \TaskLock{3}{2}{S}
  481. \end{verbatim}
  482. Unlock is similarly obtained by using command:
  483. \begin{verbatim}
  484. \TaskUnlock{3}{7}{S}
  485. \end{verbatim}
  486. Task $\tau_1$ tries to lock the same resource at time $t=5$. The
  487. priority of $\tau_1$ is then inherited by $\tau_3$: the inheritance
  488. rule is depicted by using a dashed tick arrow from the baseline of
  489. $\tau_1$ to $\tau_3$, using command:
  490. \begin{verbatim}
  491. \Inherit{1}{3}{4}
  492. \end{verbatim}
  493. The fact that $\tau_3$ is executing inside a critical section is
  494. denoted by putting a label inside the execution block, using the
  495. following command:
  496. \begin{verbatim}
  497. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  498. \end{verbatim}
  499. \begin{figure}[!htbp]
  500. \centering
  501. \begin{RTGrid}[width=12cm]{3}{25}
  502. \TaskArrDead{3}{0}{20}
  503. \TaskExecution{3}{0}{2}
  504. \TaskLock{3}{2}{S}
  505. \TaskExecution[color=white,execlabel=S]{3}{2}{3}
  506. \TaskArrDead{1}{3}{9}
  507. \TaskExecution{1}{3}{4}
  508. \TaskLock{1}{4}{S}
  509. \Inherit{1}{3}{4}
  510. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  511. \TaskArrDead{2}{5}{12}
  512. \TaskExecution[color=white,execlabel=S]{3}{5}{7}
  513. \TaskUnlock{3}{7}{S}
  514. \TaskExecution[color=white,execlabel=S]{1}{7}{9}
  515. \TaskUnlock{1}{9}{S}
  516. \TaskExecution{1}{9}{10}
  517. \TaskExecution{2}{10}{15}
  518. \TaskExecution{3}{15}{17}
  519. \end{RTGrid}
  520. \caption{Task blocking on resources: the Priority Inheritance Protocol}
  521. \label{fig:pi}
  522. \begin{verbatim}
  523. \begin{RTGrid}[width=12cm]{3}{25}
  524. \TaskArrDead{3}{0}{20}
  525. \TaskExecution{3}{0}{2}
  526. \TaskLock{3}{2}{S}
  527. \TaskExecution[color=white,execlabel=S]{3}{2}{3}
  528. \TaskArrDead{1}{3}{9}
  529. \TaskExecution{1}{3}{4}
  530. \TaskLock{1}{4}{S}
  531. \Inherit{1}{3}{4}
  532. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  533. \TaskArrDead{2}{5}{12}
  534. \TaskExecution[color=white,execlabel=S]{3}{5}{7}
  535. \TaskUnlock{3}{7}{S}
  536. \TaskExecution[color=white,execlabel=S]{1}{7}{9}
  537. \TaskUnlock{1}{9}{S}
  538. \TaskExecution{1}{9}{10}
  539. \TaskExecution{2}{10}{15}
  540. \TaskExecution{3}{15}{17}
  541. \end{RTGrid}
  542. \end{verbatim}
  543. \caption{Priority Inheritance example}
  544. \label{fig:ex4}
  545. \end{figure}
  546. \subsection{Jitter}
  547. 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 :
  548. \begin{verbatim}
  549. \TaskInterval{i}{t1}{t2}{label}
  550. \end{verbatim}
  551. 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.
  552. \begin{figure}[!htbp]
  553. \centering
  554. \begin{RTGrid}[nogrid=1, nosymbols=1 ,nonumbers=1]{3}{20}
  555. \RowLabel{1}{$\tau_i$}
  556. \TaskArrival{1}{0}
  557. \TaskExecution{1}{1}{4}
  558. \TaskDeadline{1}{7}
  559. \RowLabel{2}{msg}
  560. \TaskArrival{2}{0}
  561. \TaskExecution{2}{4}{6}
  562. \TaskDeadline{2}{8}
  563. \TaskInterval{2}{0}{4}{$J_m$} % draws an interval between date 0 and 4 for task 2 with a label J_m
  564. \RowLabel{3}{$\tau_j$}
  565. \TaskArrival{3}{0}
  566. \TaskExecution{3}{6}{9}
  567. \TaskDeadline{3}{10}
  568. \TaskInterval{3}{0}{6}{$J_j$} % draws an interval between date 0 and 6 for task 3 with a label J_j
  569. \end{RTGrid}
  570. \begin{verbatim}
  571. \begin{RTGrid}[nogrid=1, nosymbols=1 ,nonumbers=1]{3}{20}
  572. \RowLabel{1}{$\tau_i$}
  573. \TaskArrival{1}{0}
  574. \TaskExecution{1}{1}{4}
  575. \TaskDeadline{1}{7}
  576. \RowLabel{2}{msg}
  577. \TaskArrival{2}{0}
  578. \TaskExecution{2}{4}{6}
  579. \TaskDeadline{2}{8}
  580. \TaskInterval{2}{0}{4}{$J_m$} % draws an interval between date 0 and 4 for task 2 with a label J_m
  581. \RowLabel{3}{$\tau_j$}
  582. \TaskArrival{3}{0}
  583. \TaskExecution{3}{6}{9}
  584. \TaskDeadline{3}{10}
  585. \TaskInterval{3}{0}{6}{$J_j$} % draws an interval between date 0 and 6 for task 3 with a label J_j
  586. \end{RTGrid}
  587. \end{verbatim}
  588. \caption{Example with TaskInterval used to represent jitters}
  589. \label{fig:interval}
  590. \end{figure}
  591. \end{document}
  592. %%% Local Variables:
  593. %%% mode: latex
  594. %%% TeX-master: t
  595. %%% End: