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 22KB

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