Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

rtsched-doc.tex 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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, 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. \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. % draws the arrival and deadline
  158. \TaskNArrDead{2}{0}{6}{6}{3} % for 3 instances of period 6
  159. % no simple formula for lowest priority, sorry!
  160. \TaskExecution{2}{1}{4}
  161. \TaskExecution{2}{6}{8}
  162. \TaskExecution{2}{9}{10}
  163. \TaskExecution{2}{13}{16}
  164. \end{RTGrid}
  165. \begin{verbatim}
  166. \begin{RTGrid}{2}{20}
  167. \TaskNArrDead{1}{0}{4}{4}{5} % draws the arrivals and deadlines
  168. \TaskNExecDelta{1}{0}{1}{4}{5} % draws executions (highest priority)
  169. % for 5 instances of period 4
  170. \TaskNArrDead{2}{0}{6}{6}{3} % draws the arrival and deadline
  171. % for 3 instances of period 6
  172. % no simple formula for lowest priority, sorry!
  173. \TaskExecution{2}{1}{4}
  174. \TaskExecution{2}{6}{8}
  175. \TaskExecution{2}{9}{10}
  176. \TaskExecution{2}{13}{16}
  177. \end{RTGrid}
  178. \end{verbatim}
  179. \caption{Using periodic commands to avoid repetitions}
  180. \label{fig:ex1a}
  181. \end{figure}
  182. \begin{figure}[!htbp]
  183. \centering
  184. \begin{RTGrid}{3}{14}
  185. \TaskNArrival{1}{0}{3}{4} % draws only the arrivals
  186. \TaskNExecDelta{1}{0}{1}{3}{4} % draws executions (highest priority)
  187. % for 4 instances of period 3
  188. \TaskNArrival{2}{3}{4}{3} % draws only the arrivals
  189. % 3 instances of period 4, starting from 3
  190. \TaskExecDelta{2}{4}{1}
  191. \TaskExecDelta{2}{7}{1}
  192. \TaskExecDelta{2}{11}{1}
  193. % 3 instances of period 5, starting from 1
  194. \TaskNArrival{3}{1}{5}{3} % draws only the arrivals
  195. \TaskExecDelta{3}{1}{1}
  196. \TaskExecDelta{3}{8}{1}
  197. \TaskExecDelta{3}{12}{1}
  198. \end{RTGrid}
  199. \begin{verbatim}
  200. \begin{RTGrid}{3}{14}
  201. \TaskNArrival{1}{0}{3}{4} % draws only the arrivals
  202. \TaskNExecDelta{1}{0}{1}{3}{4} % draws executions (highest priority)
  203. % for 4 instances of period 3
  204. \TaskNArrival{2}{3}{4}{3} % draws only the arrivals
  205. % 3 instances of period 4, starting from 3
  206. \TaskExecDelta{2}{4}{1}
  207. \TaskExecDelta{2}{7}{1}
  208. \TaskExecDelta{2}{11}{1}
  209. % 3 instances of period 5, starting from 1
  210. \TaskNArrival{3}{1}{5}{3} % draws only the arrivals
  211. \TaskExecDelta{3}{1}{1}
  212. \TaskExecDelta{3}{8}{1}
  213. \TaskExecDelta{3}{12}{1}
  214. \end{RTGrid}
  215. \end{verbatim}
  216. \caption{Three tasks with offsets, and only arrivals with no deadlines}
  217. \label{fig:ex1b}
  218. \end{figure}
  219. \begin{figure}[!htbp]
  220. \centering
  221. \begin{RTGrid}[width=8cm]{2}{15}
  222. \TaskNArrDead{1}{0}{3}{6}{3}
  223. \TaskNArrDead{2}{2}{5}{8}{2}
  224. \end{RTGrid}
  225. \begin{verbatim}
  226. \begin{RTGrid}[width=8cm]{2}{15}
  227. \TaskNArrDead{1}{0}{3}{6}{3}
  228. \TaskNArrDead{2}{2}{5}{8}{2}
  229. \end{RTGrid}
  230. \end{verbatim}
  231. \caption{Deadlines less than periods}
  232. \label{fig:ex1c}
  233. \end{figure}
  234. It is also possible to visualise preempted tasks with a hatched fill
  235. style. An example is in Figure~\ref{fig:resp-time} that uses command
  236. \texttt{TaskRespTime}.
  237. \begin{figure}
  238. \centering
  239. \begin{RTGrid}{2}{20}
  240. \TaskNArrDead{1}{0}{4}{4}{5} % draws the arrivals and deadlines
  241. \TaskNExecDelta{1}{0}{1}{4}{5} % draws executions (highest priority)
  242. % for 5 instances of period 4
  243. \TaskNArrDead{2}{0}{6}{6}{3} % draws the arrivals and deadlines
  244. % for 3 instances of period 6
  245. \TaskRespTime{2}{0}{4} % draws the hatched rectangle in [0,4]
  246. \TaskExecution{2}{1}{4} % draws execution (over the previous rectangle)
  247. \TaskRespTime{2}{6}{4} % draws the hatched rectangle in [6,10]
  248. \TaskExecution{2}{6}{8} % draws execution
  249. \TaskExecution{2}{9}{10} % draws execution
  250. \TaskRespTime{2}{12}{4} % draws the hatched rectangle in [12,16]
  251. \TaskExecution{2}{13}{16} % draws execution
  252. \end{RTGrid}
  253. \begin{verbatim}
  254. \begin{RTGrid}{2}{20}
  255. \TaskNArrDead{1}{0}{4}{4}{5} % draws the arrivals and deadlines
  256. \TaskNExecDelta{1}{0}{1}{4}{5} % draws executions (highest priority)
  257. % for 5 instances of period 4
  258. \TaskNArrDead{2}{0}{6}{6}{3} % draws the arrivals and deadlines
  259. % for 3 instances of period 6
  260. \TaskRespTime{2}{0}{4} % draws the hatched rectangle in [0,4]
  261. \TaskExecution{2}{1}{4} % draws execution (over the previous rectangle)
  262. \TaskRespTime{2}{6}{4} % draws the hatched rectangle in [6,10]
  263. \TaskExecution{2}{6}{8} % draws execution
  264. \TaskExecution{2}{9}{10} % draws execution
  265. \TaskRespTime{2}{12}{4} % draws the hatched rectangle in [12,16]
  266. \TaskExecution{2}{13}{16} % draws execution
  267. \end{RTGrid}
  268. \end{verbatim}
  269. \caption{Example with TaskRespTime}
  270. \label{fig:resp-time}
  271. \end{figure}
  272. \subsection{Controlling visualization}
  273. It is possible to specify many options in the \texttt{RTGrid}
  274. environment. Maybe you don't like the grid: then, you can decide to
  275. not visualise it as in Figure \ref{fig:ex2}, where we also removed the
  276. task symbols.
  277. \begin{figure}[!htbp]
  278. \centering
  279. %% no grid and no symbols
  280. \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
  281. \TaskNArrDead{1}{0}{4}{4}{5}
  282. \TaskNExecDelta{1}{0}{1}{4}{5}
  283. \TaskNArrDead{2}{0}{6}{6}{3}
  284. \TaskExecution{2}{1}{4}
  285. \TaskExecution{2}{6}{8}
  286. \TaskExecution{2}{9}{10}
  287. \TaskExecution{2}{13}{16}
  288. \end{RTGrid}
  289. \begin{verbatim}
  290. %% no grid and no symbols
  291. \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
  292. \TaskNArrDead{1}{0}{4}{4}{5}
  293. \TaskNExecDelta{1}{0}{1}{4}{5}
  294. \TaskNArrDead{2}{0}{6}{6}{3}
  295. \TaskExecution{2}{1}{4}
  296. \TaskExecution{2}{6}{8}
  297. \TaskExecution{2}{9}{10}
  298. \TaskExecution{2}{13}{16}
  299. \end{RTGrid}
  300. \end{verbatim}
  301. \caption{Removing visualization of the grid and of the task names}
  302. \label{fig:ex2}
  303. \end{figure}
  304. The next figure \ref{fig:ex2a} uses different task symbols, does not
  305. show the numbers on the time line, and the color of the boxes that
  306. denote the execution of the second instance of the second task are
  307. changed to red. Also, I am changing the width, so the figure looks
  308. smaller. Notice that you can directly specify colors using the TikZ
  309. way (color!percentage for example).
  310. \begin{figure}[!htbp]
  311. \centering
  312. %% specify 1) no numbers on the time line, 2) a different symbol, 3)
  313. %% a different size of the symbol using latex size commands (default is \normalsize).
  314. %% Notice that you should not use the math mode in the
  315. %% specification of the symbol, as the symbol is already used in a
  316. %% math environment inside the macro
  317. \begin{RTGrid}[width=8cm,symbol=\gamma,nonumbers=1,labelsize=\small]{2}{20}
  318. \TaskNArrDead{1}{0}{4}{4}{5}
  319. \TaskNExecDelta{1}{0}{1}{4}{5}
  320. \TaskNArrDead{2}{0}{6}{6}{3}
  321. %% here, the border changes to cyan, and the fill to white
  322. \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
  323. %% the next two boxes are filled with red instead of gray
  324. \TaskExecution[color=red]{2}{6}{8}
  325. \TaskExecution[color=red!50]{2}{9}{10}
  326. \TaskExecution{2}{13}{16}
  327. \end{RTGrid}
  328. \begin{verbatim}
  329. %% specify 1) no numbers on the time line, 2) a different symbol, 3)
  330. %% a different size of the symbol (default is \normalsize).
  331. %% Notice that you should not use the math mode in the
  332. %% specification of the symbol, as the symbol is already used in a
  333. %% math environment inside the macro
  334. \begin{RTGrid}[symbol=\gamma,nonumbers=1,labelsize=\Large]{2}{20}
  335. \TaskNArrDead{1}{0}{4}{4}{5}
  336. \TaskNExecDelta{1}{0}{1}{4}{5}
  337. \TaskNArrDead{2}{0}{6}{6}{3}
  338. %% here, the border changes to cyan, and the fill to white
  339. \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
  340. %% the next two boxes are filled with red instead of gray
  341. \TaskExecution[color=red]{2}{6}{8}
  342. \TaskExecution[color=red]{2}{9}{10}
  343. \TaskExecution{2}{13}{16}
  344. \end{RTGrid}
  345. \end{verbatim}
  346. \caption{Different symbols (with \textbackslash Large size), no numbers, a different
  347. task color}
  348. \label{fig:ex2a}
  349. \end{figure}
  350. Do you want to specify an arbitrary symbol at a certain row?
  351. No problem! See the example in Figure \ref{fig:ex2b}. Here we use the command:
  352. \begin{verbatim}
  353. \RowLabel{i}{label}
  354. \end{verbatim}
  355. which writes the \texttt{label} at the specified row (index 1 stays at
  356. the top). Here we show also how to specify an arbitrary starting
  357. number in the time line, using the \texttt{numoffset=12} option.
  358. \begin{figure}[!htbp]
  359. \centering
  360. %% specify 1) no numbers on the time line, 2) number starting from
  361. %% 12
  362. \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
  363. %% the symbol for the first row
  364. \RowLabel{1}{Server}
  365. %% the symbol for the second row
  366. \RowLabel{2}{$\Pi_2$}
  367. \TaskNArrDead{1}{0}{4}{4}{5}
  368. \TaskNExecDelta{1}{0}{1}{4}{5}
  369. \TaskNArrDead{2}{0}{6}{6}{3}
  370. \TaskExecution{2}{1}{4}
  371. \TaskExecution{2}{6}{8}
  372. \TaskExecution{2}{9}{10}
  373. \TaskExecution{2}{13}{16}
  374. \end{RTGrid}
  375. \begin{verbatim}
  376. %% specify 1) no numbers on the time line, 2) number starting from 12
  377. \begin{RTGrid}[nosymbols=1,numoffset=12]{2}{20}
  378. %% the symbol for the first row
  379. \RowLabel{1}{Server}
  380. %% the symbol for the second row
  381. \RowLabel{2}{$\Pi_2$}
  382. \TaskNArrDead{1}{0}{4}{4}{5}
  383. \TaskNExecDelta{1}{0}{1}{4}{5}
  384. \TaskNArrDead{2}{0}{6}{6}{3}
  385. \TaskExecution{2}{1}{4}
  386. \TaskExecution{2}{6}{8}
  387. \TaskExecution{2}{9}{10}
  388. \TaskExecution{2}{13}{16}
  389. \end{RTGrid}
  390. \end{verbatim}
  391. \caption{Arbitrary symbols with an appropriate offset, no grid, numbering starting from 12}
  392. \label{fig:ex2b}
  393. \end{figure}
  394. % In the last example (Figure \ref{fig:ex2c}), we show an empty grid in
  395. % which we specify width and height.
  396. % \begin{figure}[!htbp]
  397. % \centering
  398. % %% 3 tasks, 10 units of time
  399. % \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
  400. % \end{RTGrid}
  401. % \begin{verbatim}
  402. % %% 3 tasks, 10 units of time
  403. % \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
  404. % \end{RTGrid}
  405. % \end{verbatim}
  406. % \caption{Empty grid with strange width and height}
  407. % \label{fig:ex2c}
  408. % \end{figure}
  409. \subsection{Highlighting and labeling objects}
  410. Sometimes it may be important to say that one task has caused the
  411. activation of another task. You can use the following command, as
  412. shown in Figure \ref{fig:ex3a}:
  413. \begin{verbatim}
  414. \Activation{i}{t1}{j}{t2}
  415. \end{verbatim}
  416. which draws an arrow from the baseline of task \texttt{i} at time
  417. \texttt{t1} to the baseline of task \texttt{j} at time \texttt{t2}.
  418. Also, you can put an arbitrary label inside a shadow box with the
  419. following command:
  420. \begin{verbatim}
  421. \Label{y}{x}{label}
  422. \end{verbatim}
  423. which draws a boxed label at position \texttt{x,y} in the grid.
  424. Finally, it is possible to draw a rectangular box with rounded corners
  425. to highlight a portion of the schedule with \texttt{RTBox}:
  426. \begin{verbatim}
  427. \RTBox{t1}{t2}
  428. \end{verbatim}
  429. \begin{figure}[!htbp]
  430. \centering
  431. \begin{RTGrid}{2}{20}
  432. \RTBox{12}{16}
  433. \TaskArrival{1}{0}{6}{4}
  434. \TaskExecDelta{1}{0}{2}{6}{4}
  435. \TaskArrival{2}{10}
  436. \TaskExecDelta[exeheight=1.5]{2}{10}{3}
  437. \Activation{1}{8}{2}{10}
  438. \Label{6}{7}{$\delta$}
  439. \end{RTGrid}
  440. \begin{verbatim}
  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. \end{verbatim}
  451. \caption{Activation (from one task to another one), and an arbitrary label}
  452. \label{fig:ex3a}
  453. \end{figure}
  454. Notice that the order with which the objects are drawn is exactly the
  455. same as the order in which they are specified in the code, excepted
  456. for horizontal axes, arrivals and deadlines that are always drawn on the foreground.
  457. For example, in Figure \ref{fig:ex3a}, the executions of all the tasks are
  458. drawn on top of the box. You can try to move the \texttt{RTBox}
  459. command at the end to see what happens.
  460. \subsection{Priority Inheritance}
  461. An example of task locking/unlocking and the use of the Priority
  462. Inheritance Protocol is shown in Figure \ref{fig:pi}. Here, task
  463. $\tau_3$ locks resource $S$ at time $t=2$. This is obtained by using
  464. command:
  465. \begin{verbatim}
  466. \TaskLock{3}{2}{S}
  467. \end{verbatim}
  468. Unlock is similarly obtained by using command:
  469. \begin{verbatim}
  470. \TaskUnlock{3}{7}{S}
  471. \end{verbatim}
  472. Task $\tau_1$ tries to lock the same resource at time $t=5$. The
  473. priority of $\tau_1$ is then inherited by $\tau_3$: the inheritance
  474. rule is depicted by using a dashed tick arrow from the baseline of
  475. $\tau_1$ to $\tau_3$, using command:
  476. \begin{verbatim}
  477. \Inherit{1}{3}{4}
  478. \end{verbatim}
  479. The fact that $\tau_3$ is executing inside a critical section is
  480. denoted by putting a label inside the execution block, using the
  481. following command:
  482. \begin{verbatim}
  483. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  484. \end{verbatim}
  485. \begin{figure}
  486. \centering
  487. \begin{RTGrid}[width=12cm]{3}{25}
  488. \TaskArrDead{3}{0}{20}
  489. \TaskExecution{3}{0}{2}
  490. \TaskLock{3}{2}{S}
  491. \TaskExecution[color=white,execlabel=S]{3}{2}{3}
  492. \TaskArrDead{1}{3}{9}
  493. \TaskExecution{1}{3}{4}
  494. \TaskLock{1}{4}{S}
  495. \Inherit{1}{3}{4}
  496. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  497. \TaskArrDead{2}{5}{12}
  498. \TaskExecution[color=white,execlabel=S]{3}{5}{7}
  499. \TaskUnlock{3}{7}{S}
  500. \TaskExecution[color=white,execlabel=S]{1}{7}{9}
  501. \TaskUnlock{1}{9}{S}
  502. \TaskExecution{1}{9}{10}
  503. \TaskExecution{2}{10}{15}
  504. \TaskExecution{3}{15}{17}
  505. \end{RTGrid}
  506. \caption{Task blocking on resources: the Priority Inheritance Protocol}
  507. \label{fig:pi}
  508. \begin{verbatim}
  509. \begin{RTGrid}[width=12cm]{3}{25}
  510. \TaskArrDead{3}{0}{20}
  511. \TaskExecution{3}{0}{2}
  512. \TaskLock{3}{2}{S}
  513. \TaskExecution[color=white,execlabel=S]{3}{2}{3}
  514. \TaskArrDead{1}{3}{9}
  515. \TaskExecution{1}{3}{4}
  516. \TaskLock{1}{4}{S}
  517. \Inherit{1}{3}{4}
  518. \TaskExecution[color=white,execlabel=S]{3}{4}{5}
  519. \TaskArrDead{2}{5}{12}
  520. \TaskExecution[color=white,execlabel=S]{3}{5}{7}
  521. \TaskUnlock{3}{7}{S}
  522. \TaskExecution[color=white,execlabel=S]{1}{7}{9}
  523. \TaskUnlock{1}{9}{S}
  524. \TaskExecution{1}{9}{10}
  525. \TaskExecution{2}{10}{15}
  526. \TaskExecution{3}{15}{17}
  527. \end{RTGrid}
  528. \end{verbatim}
  529. \caption{Priority Inheritance example}
  530. \label{fig:ex4}
  531. \end{figure}
  532. \end{document}
  533. %%% Local Variables:
  534. %%% mode: latex
  535. %%% TeX-master: t
  536. %%% End: