Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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