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

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