source: rtems/doc/user/rtmon.t @ e4e66d4

4.115
Last change on this file since e4e66d4 was e4e66d4, checked in by Sebastian Huber <sebastian.huber@…>, on 12/12/14 at 14:04:05

doc: Clarify rate-monotonic statistics

  • Property mode set to 100644
File size: 48.2 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2013.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5
6@c
7@c  Open Issues
8@c    - nicen up the tables
9@c    - use math mode to print formulas
10@c
11
12@chapter Rate Monotonic Manager
13
14@cindex rate mononitonic tasks
15@cindex periodic tasks
16
17@section Introduction
18
19The rate monotonic manager provides facilities to implement tasks which execute
20in a periodic fashion.  Critically, it also gathers information about the
21execution of those periods and can provide important statistics to the
22user which can be used to analyze and tune the application.  The directives
23provided by the rate monotonic manager are:
24
25@itemize @bullet
26@item @code{@value{DIRPREFIX}rate_monotonic_create} - Create a rate monotonic period
27@item @code{@value{DIRPREFIX}rate_monotonic_ident} - Get ID of a period
28@item @code{@value{DIRPREFIX}rate_monotonic_cancel} - Cancel a period
29@item @code{@value{DIRPREFIX}rate_monotonic_delete} - Delete a rate monotonic period
30@item @code{@value{DIRPREFIX}rate_monotonic_period} - Conclude current/Start next period
31@item @code{@value{DIRPREFIX}rate_monotonic_get_status} - Obtain status from a period
32@item @code{@value{DIRPREFIX}rate_monotonic_get_statistics} - Obtain statistics from a period
33@item @code{@value{DIRPREFIX}rate_monotonic_reset_statistics} - Reset statistics for a period
34@item @code{@value{DIRPREFIX}rate_monotonic_reset_all_statistics} - Reset statistics for all periods
35@item @code{@value{DIRPREFIX}rate_monotonic_report_statistics} - Print period statistics report
36@end itemize
37
38@section Background
39
40The rate monotonic manager provides facilities to
41manage the execution of periodic tasks.  This manager was
42designed to support application designers who utilize the Rate
43Monotonic Scheduling Algorithm (RMS) to ensure that their
44periodic tasks will meet their deadlines, even under transient
45overload conditions.  Although designed for hard real-time
46systems, the services provided by the rate monotonic manager may
47be used by any application which requires periodic tasks.
48
49@subsection Rate Monotonic Manager Required Support
50
51A clock tick is required to support the functionality provided by this manager.
52
53@subsection Period Statistics
54
55This manager maintains a set of statistics on each period object.  These
56statistics are reset implictly at period creation time and may be reset or
57obtained at any time by the application.  The following is a list of the
58information kept:
59
60@itemize @bullet
61@item @code{owner}
62is the id of the thread that owns this period.
63
64@item @code{count}
65is the total number of periods executed.
66
67@item @code{missed_count}
68is the number of periods that were missed.
69
70@item @code{min_cpu_time}
71is the minimum amount of CPU execution time consumed
72on any execution of the periodic loop.
73
74@item @code{max_cpu_time}
75is the maximum amount of CPU execution time consumed
76on any execution of the periodic loop.
77
78@item @code{total_cpu_time}
79is the total amount of CPU execution time consumed
80by executions of the periodic loop.
81
82@item @code{min_wall_time}
83is the minimum amount of wall time that passed
84on any execution of the periodic loop.
85
86@item @code{max_wall_time}
87is the maximum amount of wall time that passed
88on any execution of the periodic loop.
89
90@item @code{total_wall_time}
91is the total amount of wall time that passed
92during executions of the periodic loop.
93
94@end itemize
95
96Each period is divided into two consecutive phases.  The period starts with the
97active phase of the task and is followed by the inactive phase of the task.  In
98the inactive phase the task is blocked and waits for the start of the next
99period.  The inactive phase is skipped in case of a period miss.  The wall time
100includes the time during the active phase of the task on which the task is not
101executing on a processor.  The task is either blocked (for example it waits for
102a resource) or a higher priority tasks executes, thus preventing it from
103executing.  In case the wall time exceeds the period time, then this is a
104period miss.  The gap between the wall time and the period time is the margin
105between a period miss or success.
106
107The period statistics information is inexpensive to maintain
108and can provide very useful insights into the execution
109characteristics of a periodic task loop.  But it is just information.
110The period statistics reported must be analyzed by the user in terms
111of what the applications is.  For example, in an application where
112priorities are assigned by the Rate Monotonic Algorithm, it would
113be very undesirable for high priority (i.e. frequency) tasks to
114miss their period.  Similarly, in nearly any application, if a
115task were supposed to execute its periodic loop every 10 milliseconds
116and it averaged 11 milliseconds, then application requirements
117are not being met.
118
119The information reported can be used to determine the "hot spots"
120in the application.  Given a period's id, the user can determine
121the length of that period.  From that information and the CPU usage,
122the user can calculate the percentage of CPU time consumed by that
123periodic task.  For example, a task executing for 20 milliseconds
124every 200 milliseconds is consuming 10 percent of the processor's
125execution time.  This is usually enough to make it a good candidate
126for optimization.
127
128However, execution time alone is not enough to gauge the value of
129optimizing a particular task.  It is more important to optimize
130a task executing 2 millisecond every 10 milliseconds (20 percent
131of the CPU) than one executing 10 milliseconds every 100 (10 percent
132of the CPU).  As a general rule of thumb, the higher frequency at
133which a task executes, the more important it is to optimize that
134task.
135
136@subsection Rate Monotonic Manager Definitions
137
138@cindex periodic task, definition
139
140A periodic task is one which must be executed at a
141regular interval.  The interval between successive iterations of
142the task is referred to as its period.  Periodic tasks can be
143characterized by the length of their period and execution time.
144The period and execution time of a task can be used to determine
145the processor utilization for that task.  Processor utilization
146is the percentage of processor time used and can be calculated
147on a per-task or system-wide basis.  Typically, the task's
148worst-case execution time will be less than its period.  For
149example, a periodic task's requirements may state that it should
150execute for 10 milliseconds every 100 milliseconds.  Although
151the execution time may be the average, worst, or best case, the
152worst-case execution time is more appropriate for use when
153analyzing system behavior under transient overload conditions.
154
155@cindex aperiodic task, definition
156
157In contrast, an aperiodic task executes at irregular
158intervals and has only a soft deadline.  In other words, the
159deadlines for aperiodic tasks are not rigid, but adequate
160response times are desirable.  For example, an aperiodic task
161may process user input from a terminal.
162
163@cindex sporadic task, definition
164
165Finally, a sporadic task is an aperiodic task with a
166hard deadline and minimum interarrival time.  The minimum
167interarrival time is the minimum period of time which exists
168between successive iterations of the task.  For example, a
169sporadic task could be used to process the pressing of a fire
170button on a joystick.  The mechanical action of the fire button
171ensures a minimum time period between successive activations,
172but the missile must be launched by a hard deadline.
173
174@subsection Rate Monotonic Scheduling Algorithm
175
176@cindex Rate Monotonic Scheduling Algorithm, definition
177@cindex RMS Algorithm, definition
178
179The Rate Monotonic Scheduling Algorithm (RMS) is
180important to real-time systems designers because it allows one
181to guarantee that a set of tasks is schedulable.  A set of tasks
182is said to be schedulable if all of the tasks can meet their
183deadlines.  RMS provides a set of rules which can be used to
184perform a guaranteed schedulability analysis for a task set.
185This analysis determines whether a task set is schedulable under
186worst-case conditions and emphasizes the predictability of the
187system's behavior.  It has been proven that:
188
189@itemize @code{ }
190@item @b{RMS is an optimal static priority algorithm for
191scheduling independent, preemptible, periodic tasks
192on a single processor.}
193@end itemize
194
195RMS is optimal in the sense that if a set of tasks
196can be scheduled by any static priority algorithm, then RMS will
197be able to schedule that task set.  RMS bases it schedulability
198analysis on the processor utilization level below which all
199deadlines can be met.
200
201RMS calls for the static assignment of task
202priorities based upon their period.  The shorter a task's
203period, the higher its priority.  For example, a task with a 1
204millisecond period has higher priority than a task with a 100
205millisecond period.  If two tasks have the same period, then RMS
206does not distinguish between the tasks.  However, RTEMS
207specifies that when given tasks of equal priority, the task
208which has been ready longest will execute first.  RMS's priority
209assignment scheme does not provide one with exact numeric values
210for task priorities.  For example, consider the following task
211set and priority assignments:
212
213@ifset use-ascii
214@example
215@group
216+--------------------+---------------------+---------------------+
217|        Task        |       Period        |      Priority       |
218|                    |  (in milliseconds)  |                     |
219+--------------------+---------------------+---------------------+
220|         1          |         100         |         Low         |
221+--------------------+---------------------+---------------------+
222|         2          |          50         |       Medium        |
223+--------------------+---------------------+---------------------+
224|         3          |          50         |       Medium        |
225+--------------------+---------------------+---------------------+
226|         4          |          25         |        High         |
227+--------------------+---------------------+---------------------+
228@end group
229@end example
230@end ifset
231
232@ifset use-tex
233@sp 1
234@tex
235\centerline{\vbox{\offinterlineskip\halign{
236\vrule\strut#&
237\hbox to 0.75in{\enskip\hfil#\hfil}&
238\vrule#&
239\hbox to 1.25in{\enskip\hfil#\hfil}&
240\vrule#&
241\hbox to 1.25in{\enskip\hfil#\hfil}&
242\vrule#\cr\noalign{\hrule}
243&\bf Task&& \bf Period && \bf Priority &\cr
244& && \bf (in milliseconds) && &\cr\noalign{\hrule}
245& 1 && 100 && Low &\cr\noalign{\hrule}
246& 2 && 50 && Medium &\cr\noalign{\hrule}
247& 3 && 50 && Medium &\cr\noalign{\hrule}
248& 4 && 25 && High &\cr\noalign{\hrule}
249}}\hfil}
250@end tex
251@end ifset
252
253@ifset use-html
254@html
255<CENTER>
256  <TABLE COLS=3 WIDTH="80%" BORDER=2>
257<TR><TD ALIGN=center><STRONG>Task</STRONG></TD>
258    <TD ALIGN=center><STRONG>Period (in milliseconds)</STRONG></TD>
259    <TD ALIGN=center><STRONG>Priority</STRONG></TD></TR>
260<TR><TD ALIGN=center>1</TD>
261    <TD ALIGN=center>100 </TD>
262    <TD ALIGN=center>Low</TD></TR>
263<TR><TD ALIGN=center>2</TD>
264    <TD ALIGN=center>50 </TD>
265    <TD ALIGN=center>Medium</TD></TR>
266<TR><TD ALIGN=center>3</TD>
267    <TD ALIGN=center>50 </TD>
268    <TD ALIGN=center>Medium</TD></TR>
269<TR><TD ALIGN=center>4</TD>
270    <TD ALIGN=center>25 </TD>
271    <TD ALIGN=center>High</TD></TR>
272  </TABLE>
273</CENTER>
274@end html
275@end ifset
276
277RMS only calls for task 1 to have the lowest
278priority, task 4 to have the highest priority, and tasks 2 and 3
279to have an equal priority between that of tasks 1 and 4.  The
280actual RTEMS priorities assigned to the tasks must only adhere
281to those guidelines.
282
283Many applications have tasks with both hard and soft
284deadlines.  The tasks with hard deadlines are typically referred
285to as the critical task set, with the soft deadline tasks being
286the non-critical task set.  The critical task set can be
287scheduled using RMS, with the non-critical tasks not executing
288under transient overload, by simply assigning priorities such
289that the lowest priority critical task (i.e. longest period) has
290a higher priority than the highest priority non-critical task.
291Although RMS may be used to assign priorities to the
292non-critical tasks, it is not necessary.  In this instance,
293schedulability is only guaranteed for the critical task set.
294
295@subsection Schedulability Analysis
296
297@cindex RMS schedulability analysis
298
299RMS allows application designers to ensure that tasks
300can meet all deadlines, even under transient overload, without
301knowing exactly when any given task will execute by applying
302proven schedulability analysis rules.
303
304@subsubsection Assumptions
305
306The schedulability analysis rules for RMS were
307developed based on the following assumptions:
308
309
310@itemize @bullet
311@item The requests for all tasks for which hard deadlines
312exist are periodic, with a constant interval between requests.
313
314@item Each task must complete before the next request for it
315occurs.
316
317@item The tasks are independent in that a task does not depend
318on the initiation or completion of requests for other tasks.
319
320@item The execution time for each task without preemption or
321interruption is constant and does not vary.
322
323@item Any non-periodic tasks in the system are special.  These
324tasks displace periodic tasks while executing and do not have
325hard, critical deadlines.
326@end itemize
327
328Once the basic schedulability analysis is understood,
329some of the above assumptions can be relaxed and the
330side-effects accounted for.
331
332@subsubsection Processor Utilization Rule
333
334@cindex RMS Processor Utilization Rule
335
336The Processor Utilization Rule requires that
337processor utilization be calculated based upon the period and
338execution time of each task.  The fraction of processor time
339spent executing task index is Time(index) / Period(index).  The
340processor utilization can be calculated as follows:
341
342@example
343@group
344Utilization = 0
345
346for index = 1 to maximum_tasks
347  Utilization = Utilization + (Time(index)/Period(index))
348@end group
349@end example
350
351To ensure schedulability even under transient
352overload, the processor utilization must adhere to the following
353rule:
354
355@example
356Utilization = maximum_tasks * (2**(1/maximum_tasks) - 1)
357@end example
358
359As the number of tasks increases, the above formula
360approaches ln(2) for a worst-case utilization factor of
361approximately 0.693.  Many tasks sets can be scheduled with a
362greater utilization factor.  In fact, the average processor
363utilization threshold for a randomly generated task set is
364approximately 0.88.
365
366@subsubsection Processor Utilization Rule Example
367
368This example illustrates the application of the
369Processor Utilization Rule to an application with three critical
370periodic tasks.  The following table details the RMS priority,
371period, execution time, and processor utilization for each task:
372
373@ifset use-ascii
374@example
375@group
376    +------------+----------+--------+-----------+-------------+
377    |    Task    |   RMS    | Period | Execution |  Processor  |
378    |            | Priority |        |   Time    | Utilization |
379    +------------+----------+--------+-----------+-------------+
380    |     1      |   High   |  100   |    15     |    0.15     |
381    +------------+----------+--------+-----------+-------------+
382    |     2      |  Medium  |  200   |    50     |    0.25     |
383    +------------+----------+--------+-----------+-------------+
384    |     3      |   Low    |  300   |   100     |    0.33     |
385    +------------+----------+--------+-----------+-------------+
386@end group
387@end example
388@end ifset
389
390@ifset use-tex
391@sp 1
392@tex
393\centerline{\vbox{\offinterlineskip\halign{
394\vrule\strut#&
395\hbox to 0.75in{\enskip\hfil#\hfil}&
396\vrule#&
397\hbox to 0.75in{\enskip\hfil#\hfil}&
398\vrule#&
399\hbox to 0.75in{\enskip\hfil#\hfil}&
400\vrule#&
401\hbox to 1.00in{\enskip\hfil#\hfil}&
402\vrule#&
403\hbox to 1.00in{\enskip\hfil#\hfil}&
404\vrule#\cr\noalign{\hrule}
405&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
406& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
407& 1 && High && 100 && 15 && 0.15 &\cr\noalign{\hrule}
408& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
409& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
410}}\hfil}
411@end tex
412@end ifset
413 
414@ifset use-html
415@html
416<CENTER>
417  <TABLE COLS=5 WIDTH="80%" BORDER=2>
418<TR><TD ALIGN=center><STRONG>Task</STRONG></TD>
419    <TD ALIGN=center><STRONG>RMS Priority</STRONG></TD>
420    <TD ALIGN=center><STRONG>Period</STRONG></TD>
421    <TD ALIGN=center><STRONG>Execution Time</STRONG></TD>
422    <TD ALIGN=center><STRONG>Processor Utilization</STRONG></TD></TR>
423<TR><TD ALIGN=center>1</TD>
424    <TD ALIGN=center>High</TD>
425    <TD ALIGN=center>100</TD>
426    <TD ALIGN=center>15</TD>
427    <TD ALIGN=center>0.15</TD></TR>
428<TR><TD ALIGN=center>2</TD>
429    <TD ALIGN=center>Medium</TD>
430    <TD ALIGN=center>200</TD>
431    <TD ALIGN=center>50</TD>
432    <TD ALIGN=center>0.25</TD></TR>
433<TR><TD ALIGN=center>3</TD>
434    <TD ALIGN=center>Low</TD>
435    <TD ALIGN=center>300</TD>
436    <TD ALIGN=center>100</TD>
437    <TD ALIGN=center>0.33</TD></TR>
438  </TABLE>
439</CENTER>
440@end html
441@end ifset
442
443The total processor utilization for this task set is
4440.73 which is below the upper bound of 3 * (2**(1/3) - 1), or
4450.779, imposed by the Processor Utilization Rule.  Therefore,
446this task set is guaranteed to be schedulable using RMS.
447
448@subsubsection First Deadline Rule
449
450@cindex RMS First Deadline Rule
451
452If a given set of tasks do exceed the processor
453utilization upper limit imposed by the Processor Utilization
454Rule, they can still be guaranteed to meet all their deadlines
455by application of the First Deadline Rule.  This rule can be
456stated as follows:
457
458For a given set of independent periodic tasks, if
459each task meets its first deadline when all tasks are started at
460the same time, then the deadlines will always be met for any
461combination of start times.
462
463A key point with this rule is that ALL periodic tasks
464are assumed to start at the exact same instant in time.
465Although this assumption may seem to be invalid,  RTEMS makes it
466quite easy to ensure.  By having a non-preemptible user
467initialization task, all application tasks, regardless of
468priority, can be created and started before the initialization
469deletes itself.  This technique ensures that all tasks begin to
470compete for execution time at the same instant -- when the user
471initialization task deletes itself.
472
473@subsubsection First Deadline Rule Example
474
475The First Deadline Rule can ensure schedulability
476even when the Processor Utilization Rule fails.  The example
477below is a modification of the Processor Utilization Rule
478example where task execution time has been increased from 15 to
47925 units.  The following table details the RMS priority, period,
480execution time, and processor utilization for each task:
481
482@ifset use-ascii
483@example
484@group
485    +------------+----------+--------+-----------+-------------+
486    |    Task    |   RMS    | Period | Execution |  Processor  |
487    |            | Priority |        |   Time    | Utilization |
488    +------------+----------+--------+-----------+-------------+
489    |     1      |   High   |  100   |    25     |    0.25     |
490    +------------+----------+--------+-----------+-------------+
491    |     2      |  Medium  |  200   |    50     |    0.25     |
492    +------------+----------+--------+-----------+-------------+
493    |     3      |   Low    |  300   |   100     |    0.33     |
494    +------------+----------+--------+-----------+-------------+
495@end group
496@end example
497@end ifset
498
499@ifset use-tex
500@sp 1
501@tex
502\centerline{\vbox{\offinterlineskip\halign{
503\vrule\strut#&
504\hbox to 0.75in{\enskip\hfil#\hfil}&
505\vrule#&
506\hbox to 0.75in{\enskip\hfil#\hfil}&
507\vrule#&
508\hbox to 0.75in{\enskip\hfil#\hfil}&
509\vrule#&
510\hbox to 1.00in{\enskip\hfil#\hfil}&
511\vrule#&
512\hbox to 1.00in{\enskip\hfil#\hfil}&
513\vrule#\cr\noalign{\hrule}
514&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
515& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
516& 1 && High && 100 && 25 && 0.25 &\cr\noalign{\hrule}
517& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
518& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
519}}\hfil}
520@end tex
521@end ifset
522 
523@ifset use-html
524@html
525<CENTER>
526  <TABLE COLS=5 WIDTH="80%" BORDER=2>
527<TR><TD ALIGN=center><STRONG>Task</STRONG></TD>
528    <TD ALIGN=center><STRONG>RMS Priority</STRONG></TD>
529    <TD ALIGN=center><STRONG>Period</STRONG></TD>
530    <TD ALIGN=center><STRONG>Execution Time</STRONG></TD>
531    <TD ALIGN=center><STRONG>Processor Utilization</STRONG></TD></TR>
532<TR><TD ALIGN=center>1</TD>
533    <TD ALIGN=center>High</TD>
534    <TD ALIGN=center>100</TD>
535    <TD ALIGN=center>25</TD>
536    <TD ALIGN=center>0.25</TD></TR>
537<TR><TD ALIGN=center>2</TD>
538    <TD ALIGN=center>Medium</TD>
539    <TD ALIGN=center>200</TD>
540    <TD ALIGN=center>50</TD>
541    <TD ALIGN=center>0.25</TD></TR>
542<TR><TD ALIGN=center>3</TD>
543    <TD ALIGN=center>Low</TD>
544    <TD ALIGN=center>300</TD>
545    <TD ALIGN=center>100</TD>
546    <TD ALIGN=center>0.33</TD></TR>
547  </TABLE>
548</CENTER>
549@end html
550@end ifset
551
552The total processor utilization for the modified task
553set is 0.83 which is above the upper bound of 3 * (2**(1/3) - 1),
554or 0.779, imposed by the Processor Utilization Rule.  Therefore,
555this task set is not guaranteed to be schedulable using RMS.
556However, the First Deadline Rule can guarantee the
557schedulability of this task set.  This rule calls for one to
558examine each occurrence of deadline until either all tasks have
559met their deadline or one task failed to meet its first
560deadline.  The following table details the time of each deadline
561occurrence, the maximum number of times each task may have run,
562the total execution time, and whether all the deadlines have
563been met.
564
565@ifset use-ascii
566@example
567@group
568+----------+------+------+------+----------------------+---------------+
569| Deadline | Task | Task | Task |        Total         | All Deadlines |
570|   Time   |  1   |  2   |  3   |    Execution Time    |     Met?      |
571+----------+------+------+------+----------------------+---------------+
572|   100    |  1   |  1   |  1   |  25 + 50 + 100 = 175 |      NO       |
573+----------+------+------+------+----------------------+---------------+
574|   200    |  2   |  1   |  1   |  50 + 50 + 100 = 200 |     YES       |
575+----------+------+------+------+----------------------+---------------+
576@end group
577@end example
578@end ifset
579
580@ifset use-tex
581@sp 1
582@tex
583\centerline{\vbox{\offinterlineskip\halign{
584\vrule\strut#&
585\hbox to 0.75in{\enskip\hfil#\hfil}&
586\vrule#&
587\hbox to 0.75in{\enskip\hfil#\hfil}&
588\vrule#&
589\hbox to 0.75in{\enskip\hfil#\hfil}&
590\vrule#&
591\hbox to 0.75in{\enskip\hfil#\hfil}&
592\vrule#&
593\hbox to 2.00in{\enskip\hfil#\hfil}&
594\vrule#&
595\hbox to 1.00in{\enskip\hfil#\hfil}&
596\vrule#\cr\noalign{\hrule}
597&\bf Deadline&& \bf Task &&\bf Task&&\bf Task&&\bf Total          &&\bf All Deadlines &\cr
598&\bf Time    && \bf 1    &&\bf 2   &&\bf 3   &&\bf Execution Time &&\bf Net?&\cr\noalign{\hrule}
599& 100&& 1 && 1 && 1 && 25 + 50 + 100 = 175 && NO &\cr\noalign{\hrule}
600& 200&& 2 && 1 && 1 && 50 + 50 + 100 = 200 && YES &\cr\noalign{\hrule}
601}}\hfil}
602@end tex
603@end ifset
604 
605@ifset use-html
606@html
607<CENTER>
608  <TABLE COLS=6 WIDTH="80%" BORDER=2>
609<TR><TD ALIGN=center><STRONG>Deadline Time</STRONG></TD>
610    <TD ALIGN=center><STRONG>Task 1</STRONG></TD>
611    <TD ALIGN=center><STRONG>Task 2</STRONG></TD>
612    <TD ALIGN=center><STRONG>Task 3</STRONG></TD>
613    <TD ALIGN=center><STRONG>Total Execution Time</STRONG></TD>
614    <TD ALIGN=center><STRONG>All Deadlines Met?</STRONG></TD></TR>
615<TR><TD ALIGN=center>100</TD>
616    <TD ALIGN=center>1</TD>
617    <TD ALIGN=center>1</TD>
618    <TD ALIGN=center>1</TD>
619    <TD ALIGN=center>25 + 50 + 100 = 175</TD>
620    <TD ALIGN=center>NO</TD></TR>
621<TR><TD ALIGN=center>200</TD>
622    <TD ALIGN=center>2</TD>
623    <TD ALIGN=center>1</TD>
624    <TD ALIGN=center>1</TD>
625    <TD ALIGN=center>50 + 50 + 100 = 175</TD>
626    <TD ALIGN=center>YES</TD></TR>
627  </TABLE>
628</CENTER>
629@end html
630@end ifset
631
632The key to this analysis is to recognize when each
633task will execute.  For example at time 100, task 1 must have
634met its first deadline, but tasks 2 and 3 may also have begun
635execution.  In this example, at time 100 tasks 1 and 2 have
636completed execution and thus have met their first deadline.
637Tasks 1 and 2 have used (25 + 50) = 75 time units, leaving (100
638- 75) = 25 time units for task 3 to begin.  Because task 3 takes
639100 ticks to execute, it will not have completed execution at
640time 100.  Thus at time 100, all of the tasks except task 3 have
641met their first deadline.
642
643At time 200, task 1 must have met its second deadline
644and task 2 its first deadline.  As a result, of the first 200
645time units, task 1 uses (2 * 25) = 50 and task 2 uses 50,
646leaving (200 - 100) time units for task 3.  Task 3 requires 100
647time units to execute, thus it will have completed execution at
648time 200.  Thus, all of the tasks have met their first deadlines
649at time 200, and the task set is schedulable using the First
650Deadline Rule.
651
652@subsubsection Relaxation of Assumptions
653
654The assumptions used to develop the RMS
655schedulability rules are uncommon in most real-time systems.
656For example, it was assumed that tasks have constant unvarying
657execution time.  It is possible to relax this assumption, simply
658by using the worst-case execution time of each task.
659
660Another assumption is that the tasks are independent.
661This means that the tasks do not wait for one another or
662contend for resources.  This assumption can be relaxed by
663accounting for the amount of time a task spends waiting to
664acquire resources.  Similarly, each task's execution time must
665account for any I/O performed and any RTEMS directive calls.
666
667In addition, the assumptions did not account for the
668time spent executing interrupt service routines.  This can be
669accounted for by including all the processor utilization by
670interrupt service routines in the utilization calculation.
671Similarly, one should also account for the impact of delays in
672accessing local memory caused by direct memory access and other
673processors accessing local dual-ported memory.
674
675The assumption that nonperiodic tasks are used only
676for initialization or failure-recovery can be relaxed by placing
677all periodic tasks in the critical task set.  This task set can
678be scheduled and analyzed using RMS.  All nonperiodic tasks are
679placed in the non-critical task set.  Although the critical task
680set can be guaranteed to execute even under transient overload,
681the non-critical task set is not guaranteed to execute.
682
683In conclusion, the application designer must be fully
684cognizant of the system and its run-time behavior when
685performing schedulability analysis for a system using RMS.
686Every hardware and software factor which impacts the execution
687time of each task must be accounted for in the schedulability
688analysis.
689
690@subsubsection Further Reading
691
692For more information on Rate Monotonic Scheduling and
693its schedulability analysis, the reader is referred to the
694following:
695
696@itemize @code{ }
697@item @cite{C. L. Liu and J. W. Layland. "Scheduling Algorithms for
698Multiprogramming in a Hard Real Time Environment." @b{Journal of
699the Association of Computing Machinery}. January 1973. pp. 46-61.}
700
701@item @cite{John Lehoczky, Lui Sha, and Ye Ding. "The Rate Monotonic
702Scheduling Algorithm: Exact Characterization and Average Case
703Behavior."  @b{IEEE Real-Time Systems Symposium}. 1989. pp. 166-171.}
704
705@item @cite{Lui Sha and John Goodenough. "Real-Time Scheduling
706Theory and Ada."  @b{IEEE Computer}. April 1990. pp. 53-62.}
707
708@item @cite{Alan Burns. "Scheduling hard real-time systems: a
709review."  @b{Software Engineering Journal}. May 1991. pp. 116-128.}
710@end itemize
711
712@section Operations
713
714@subsection Creating a Rate Monotonic Period
715
716The @code{@value{DIRPREFIX}rate_monotonic_create} directive creates a rate
717monotonic period which is to be used by the calling task to
718delineate a period.  RTEMS allocates a Period Control Block
719(PCB) from the PCB free list.  This data structure is used by
720RTEMS to manage the newly created rate monotonic period.  RTEMS
721returns a unique period ID to the application which is used by
722other rate monotonic manager directives to access this rate
723monotonic period.
724
725@subsection Manipulating a Period
726
727The @code{@value{DIRPREFIX}rate_monotonic_period} directive is used to
728establish and maintain periodic execution utilizing a previously
729created rate monotonic period.   Once initiated by the
730@code{@value{DIRPREFIX}rate_monotonic_period} directive, the period is
731said to run until it either expires or is reinitiated.  The state of the rate
732monotonic period results in one of the following scenarios:
733
734@itemize @bullet
735@item If the rate monotonic period is running, the calling
736task will be blocked for the remainder of the outstanding period
737and, upon completion of that period, the period will be
738reinitiated with the specified period.
739
740@item If the rate monotonic period is not currently running
741and has not expired, it is initiated with a length of period
742ticks and the calling task returns immediately.
743
744@item If the rate monotonic period has expired before the task
745invokes the @code{@value{DIRPREFIX}rate_monotonic_period} directive,
746the period will be initiated with a length of period ticks and the calling task
747returns immediately with a timeout error status.
748
749@end itemize
750
751@subsection Obtaining the Status of a Period
752
753If the @code{@value{DIRPREFIX}rate_monotonic_period} directive is invoked
754with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the current
755state of the specified rate monotonic period will be returned.  The following
756table details the relationship between the period's status and
757the directive status code returned by the
758@code{@value{DIRPREFIX}rate_monotonic_period}
759directive:
760
761@itemize @bullet
762@item @code{@value{RPREFIX}SUCCESSFUL} - period is running
763
764@item @code{@value{RPREFIX}TIMEOUT} - period has expired
765
766@item @code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated
767@end itemize
768
769Obtaining the status of a rate monotonic period does
770not alter the state or length of that period.
771
772@subsection Canceling a Period
773
774The @code{@value{DIRPREFIX}rate_monotonic_cancel} directive is used to stop
775the period maintained by the specified rate monotonic period.
776The period is stopped and the rate monotonic period can be
777reinitiated using the @code{@value{DIRPREFIX}rate_monotonic_period} directive.
778
779@subsection Deleting a Rate Monotonic Period
780
781The @code{@value{DIRPREFIX}rate_monotonic_delete} directive is used to delete
782a rate monotonic period.  If the period is running and has not
783expired, the period is automatically canceled.  The rate
784monotonic period's control block is returned to the PCB free
785list when it is deleted.  A rate monotonic period can be deleted
786by a task other than the task which created the period.
787
788@subsection Examples
789
790The following sections illustrate common uses of rate
791monotonic periods to construct periodic tasks.
792
793@subsection Simple Periodic Task
794
795This example consists of a single periodic task
796which, after initialization, executes every 100 clock ticks.
797
798@page
799@example
800rtems_task Periodic_task(rtems_task_argument arg)
801@{
802  rtems_name        name;
803  rtems_id          period;
804  rtems_status_code status;
805
806  name = rtems_build_name( 'P', 'E', 'R', 'D' );
807
808  status = rtems_rate_monotonic_create( name, &period );
809  if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
810    printf( "rtems_monotonic_create failed with status of %d.\n", rc );
811    exit( 1 );
812  @}
813
814
815  while ( 1 ) @{
816    if ( rtems_rate_monotonic_period( period, 100 ) == RTEMS_TIMEOUT )
817      break;
818
819    /* Perform some periodic actions */
820  @}
821
822  /* missed period so delete period and SELF */
823
824  status = rtems_rate_monotonic_delete( period );
825  if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
826    printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
827    exit( 1 );
828  @}
829
830  status = rtems_task_delete( SELF );    /* should not return */
831  printf( "rtems_task_delete returned with status of %d.\n", status );
832  exit( 1 );
833@}
834@end example
835
836The above task creates a rate monotonic period as
837part of its initialization.  The first time the loop is
838executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
839directive will initiate the period for 100 ticks and return
840immediately.  Subsequent invocations of the
841@code{@value{DIRPREFIX}rate_monotonic_period} directive will result
842in the task blocking for the remainder of the 100 tick period.
843If, for any reason, the body of the loop takes more than 100
844ticks to execute, the @code{@value{DIRPREFIX}rate_monotonic_period}
845directive will return the @code{@value{RPREFIX}TIMEOUT} status. 
846If the above task misses its deadline, it will delete the rate
847monotonic period and itself.
848
849@subsection Task with Multiple Periods
850
851This example consists of a single periodic task
852which, after initialization, performs two sets of actions every
853100 clock ticks.  The first set of actions is performed in the
854first forty clock ticks of every 100 clock ticks, while the
855second set of actions is performed between the fortieth and
856seventieth clock ticks.  The last thirty clock ticks are not
857used by this task.
858
859@page
860@example
861rtems_task Periodic_task(rtems_task_argument arg)
862@{
863  rtems_name        name_1, name_2;
864  rtems_id          period_1, period_2;
865  rtems_status_code status;
866
867  name_1 = rtems_build_name( 'P', 'E', 'R', '1' );
868  name_2 = rtems_build_name( 'P', 'E', 'R', '2' );
869
870  (void ) rtems_rate_monotonic_create( name_1, &period_1 );
871  (void ) rtems_rate_monotonic_create( name_2, &period_2 );
872
873  while ( 1 ) @{
874    if ( rtems_rate_monotonic_period( period_1, 100 ) == TIMEOUT )
875      break;
876
877    if ( rtems_rate_monotonic_period( period_2, 40 ) == TIMEOUT )
878      break;
879
880    /*
881     *  Perform first set of actions between clock
882     *  ticks 0 and 39 of every 100 ticks.
883     */
884
885    if ( rtems_rate_monotonic_period( period_2, 30 ) == TIMEOUT )
886      break;
887
888    /*
889     *  Perform second set of actions between clock 40 and 69
890     *  of every 100 ticks.  THEN ...
891     *
892     *  Check to make sure we didn't miss the period_2 period.
893     */
894
895    if ( rtems_rate_monotonic_period( period_2, STATUS ) == TIMEOUT )
896      break;
897
898    (void) rtems_rate_monotonic_cancel( period_2 );
899  @}
900
901  /* missed period so delete period and SELF */
902
903  (void ) rtems_rate_monotonic_delete( period_1 );
904  (void ) rtems_rate_monotonic_delete( period_2 );
905  (void ) task_delete( SELF );
906@}
907@end example
908
909The above task creates two rate monotonic periods as
910part of its initialization.  The first time the loop is
911executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
912directive will initiate the period_1 period for 100 ticks
913and return immediately.  Subsequent invocations of the
914@code{@value{DIRPREFIX}rate_monotonic_period} directive
915for period_1 will result in the task blocking for the remainder
916of the 100 tick period.  The period_2 period is used to control
917the execution time of the two sets of actions within each 100
918tick period established by period_1.  The
919@code{@value{DIRPREFIX}rate_monotonic_cancel( period_2 )}
920call is performed to ensure that the period_2 period
921does not expire while the task is blocked on the period_1
922period.  If this cancel operation were not performed, every time
923the @code{@value{DIRPREFIX}rate_monotonic_period( period_2, 40 )}
924call is executed, except for the initial one, a directive status
925of @code{@value{RPREFIX}TIMEOUT} is returned.  It is important to
926note that every time this call is made, the period_2 period will be
927initiated immediately and the task will not block.
928
929If, for any reason, the task misses any deadline, the
930@code{@value{DIRPREFIX}rate_monotonic_period} directive will
931return the @code{@value{RPREFIX}TIMEOUT}
932directive status.  If the above task misses its deadline, it
933will delete the rate monotonic periods and itself.
934
935@section Directives
936
937This section details the rate monotonic manager's
938directives.  A subsection is dedicated to each of this manager's
939directives and describes the calling sequence, related
940constants, usage, and status codes.
941
942@c
943@c
944@c
945@page
946@subsection RATE_MONOTONIC_CREATE - Create a rate monotonic period
947
948@cindex create a period
949
950@subheading CALLING SEQUENCE:
951
952@ifset is-C
953@findex rtems_rate_monotonic_create
954@example
955rtems_status_code rtems_rate_monotonic_create(
956  rtems_name  name,
957  rtems_id   *id
958);
959@end example
960@end ifset
961
962@ifset is-Ada
963@example
964procedure Rate_Monotonic_Create (
965   Name   : in     RTEMS.Name;
966   ID     :    out RTEMS.ID;
967   Result :    out RTEMS.Status_Codes
968);
969@end example
970@end ifset
971
972@subheading DIRECTIVE STATUS CODES:
973@code{@value{RPREFIX}SUCCESSFUL} - rate monotonic period created successfully@*
974@code{@value{RPREFIX}INVALID_NAME} - invalid period name@*
975@code{@value{RPREFIX}TOO_MANY} - too many periods created
976
977@subheading DESCRIPTION:
978
979This directive creates a rate monotonic period.  The
980assigned rate monotonic id is returned in id.  This id is used
981to access the period with other rate monotonic manager
982directives.  For control and maintenance of the rate monotonic
983period, RTEMS allocates a PCB from the local PCB free pool and
984initializes it.
985
986@subheading NOTES:
987
988This directive will not cause the calling task to be
989preempted.
990
991@c
992@c
993@c
994@page
995@subsection RATE_MONOTONIC_IDENT - Get ID of a period
996
997@cindex get ID of a period
998@cindex obtain ID of a period
999
1000@subheading CALLING SEQUENCE:
1001
1002@ifset is-C
1003@findex rtems_rate_monotonic_ident
1004@example
1005rtems_status_code rtems_rate_monotonic_ident(
1006  rtems_name  name,
1007  rtems_id   *id
1008);
1009@end example
1010@end ifset
1011
1012@ifset is-Ada
1013@example
1014procedure Rate_Monotonic_Ident (
1015   Name   : in     RTEMS.Name;
1016   ID     :    out RTEMS.ID;
1017   Result :    out RTEMS.Status_Codes
1018);
1019@end example
1020@end ifset
1021
1022@subheading DIRECTIVE STATUS CODES:
1023@code{@value{RPREFIX}SUCCESSFUL} - period identified successfully@*
1024@code{@value{RPREFIX}INVALID_NAME} - period name not found
1025
1026@subheading DESCRIPTION:
1027
1028This directive obtains the period id associated with
1029the period name to be acquired.  If the period name is not
1030unique, then the period id will match one of the periods with
1031that name.  However, this period id is not guaranteed to
1032correspond to the desired period.  The period id is used to
1033access this period in other rate monotonic manager directives.
1034
1035@subheading NOTES:
1036
1037This directive will not cause the running task to be
1038preempted.
1039
1040@c
1041@c
1042@c
1043@page
1044@subsection RATE_MONOTONIC_CANCEL - Cancel a period
1045
1046@cindex cancel a period
1047
1048@subheading CALLING SEQUENCE:
1049
1050@ifset is-C
1051@findex rtems_rate_monotonic_cancel
1052@example
1053rtems_status_code rtems_rate_monotonic_cancel(
1054  rtems_id id
1055);
1056@end example
1057@end ifset
1058
1059@ifset is-Ada
1060@example
1061procedure Rate_Monotonic_Cancel (
1062   ID     : in     RTEMS.ID;
1063   Result :    out RTEMS.Status_Codes
1064);
1065@end example
1066@end ifset
1067
1068@subheading DIRECTIVE STATUS CODES:
1069@code{@value{RPREFIX}SUCCESSFUL} - period canceled successfully@*
1070@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
1071@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - rate monotonic period not created by calling task
1072
1073@subheading DESCRIPTION:
1074
1075This directive cancels the rate monotonic period id.
1076This period will be reinitiated by the next invocation of
1077@code{@value{DIRPREFIX}rate_monotonic_period} with id.
1078
1079@subheading NOTES:
1080
1081This directive will not cause the running task to be
1082preempted.
1083
1084The rate monotonic period specified by id must have
1085been created by the calling task.
1086
1087@c
1088@c
1089@c
1090@page
1091@subsection RATE_MONOTONIC_DELETE - Delete a rate monotonic period
1092
1093@cindex delete a period
1094
1095@subheading CALLING SEQUENCE:
1096
1097@ifset is-C
1098@findex rtems_rate_monotonic_delete
1099@example
1100rtems_status_code rtems_rate_monotonic_delete(
1101  rtems_id id
1102);
1103@end example
1104@end ifset
1105
1106@ifset is-Ada
1107@example
1108procedure Rate_Monotonic_Delete (
1109   ID     : in     RTEMS.ID;
1110   Result :    out RTEMS.Status_Codes
1111);
1112@end example
1113@end ifset
1114
1115@subheading DIRECTIVE STATUS CODES:
1116@code{@value{RPREFIX}SUCCESSFUL} - period deleted successfully@*
1117@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id
1118
1119@subheading DESCRIPTION:
1120
1121This directive deletes the rate monotonic period
1122specified by id.  If the period is running, it is automatically
1123canceled.  The PCB for the deleted period is reclaimed by RTEMS.
1124
1125@subheading NOTES:
1126
1127This directive will not cause the running task to be
1128preempted.
1129
1130A rate monotonic period can be deleted by a task
1131other than the task which created the period.
1132
1133@c
1134@c
1135@c
1136@page
1137@subsection RATE_MONOTONIC_PERIOD - Conclude current/Start next period
1138
1139@cindex conclude current period
1140@cindex start current period
1141@cindex period initiation
1142
1143@subheading CALLING SEQUENCE:
1144
1145@ifset is-C
1146@findex rtems_rate_monotonic_period
1147@example
1148rtems_status_code rtems_rate_monotonic_period(
1149  rtems_id       id,
1150  rtems_interval length
1151);
1152@end example
1153@end ifset
1154
1155@ifset is-Ada
1156@example
1157procedure Rate_Monotonic_Period (
1158   ID      : in     RTEMS.ID;
1159   Length  : in     RTEMS.Interval;
1160   Result  :    out RTEMS.Status_Codes
1161);
1162@end example
1163@end ifset
1164
1165@subheading DIRECTIVE STATUS CODES:
1166@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
1167@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
1168@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - period not created by calling task@*
1169@code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated (only
1170possible when period is set to PERIOD_STATUS)@*
1171@code{@value{RPREFIX}TIMEOUT} - period has expired
1172
1173@subheading DESCRIPTION:
1174
1175This directive initiates the rate monotonic period id
1176with a length of period ticks.  If id is running, then the
1177calling task will block for the remainder of the period before
1178reinitiating the period with the specified period.  If id was
1179not running (either expired or never initiated), the period is
1180immediately initiated and the directive returns immediately.
1181
1182If invoked with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the
1183current state of id will be returned.  The directive status
1184indicates the current state of the period.  This does not alter
1185the state or period of the period.
1186
1187@subheading NOTES:
1188
1189This directive will not cause the running task to be preempted.
1190
1191@c
1192@c
1193@c
1194@page
1195@subsection RATE_MONOTONIC_GET_STATUS - Obtain status from a period
1196
1197@cindex get status of period
1198@cindex obtain status of period
1199
1200@subheading CALLING SEQUENCE:
1201
1202@ifset is-C
1203@findex rtems_rate_monotonic_get_status
1204@example
1205rtems_status_code rtems_rate_monotonic_get_status(
1206  rtems_id                            id,
1207  rtems_rate_monotonic_period_status *status
1208);
1209@end example
1210@end ifset
1211
1212@ifset is-Ada
1213@example
1214procedure Rate_Monotonic_Get_Status (
1215   ID      : in     RTEMS.ID;
1216   Status  :    out RTEMS.Rate_Monotonic_Period_Status;
1217   Result  :    out RTEMS.Status_Codes
1218);
1219@end example
1220@end ifset
1221
1222@subheading DIRECTIVE STATUS CODES:
1223@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
1224@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
1225@code{@value{RPREFIX}INVALID_ADDRESS} - invalid address of status@*
1226
1227@subheading DESCRIPTION:
1228
1229This directive returns status information associated with
1230the rate monotonic period id in the following data @value{STRUCTURE}:
1231
1232@ifset is-C
1233@findex rtems_rate_monotonic_period_status
1234@example
1235typedef struct @{
1236  rtems_id                              owner;
1237  rtems_rate_monotonic_period_states    state;
1238  rtems_rate_monotonic_period_time_t    since_last_period;
1239  rtems_thread_cpu_usage_t              executed_since_last_period;
1240@}  rtems_rate_monotonic_period_status;
1241@end example
1242@end ifset
1243
1244@ifset is-Ada
1245@example
1246type Rate_Monotonic_Period_Status is
1247   begin
1248      Owner                      : RTEMS.ID;
1249      State                      : RTEMS.Rate_Monotonic_Period_States;
1250      Since_Last_Period          : RTEMS.Unsigned32;
1251      Executed_Since_Last_Period : RTEMS.Unsigned32;
1252   end record;
1253@end example
1254@end ifset
1255
1256@c RATE_MONOTONIC_INACTIVE does not have RTEMS_ in front of it.
1257
1258A configure time option can be used to select whether the time information is
1259given in ticks or seconds and nanoseconds.  The default is seconds and
1260nanoseconds.  If the period's state is @code{RATE_MONOTONIC_INACTIVE}, both
1261time values will be set to 0.  Otherwise, both time values will contain
1262time information since the last invocation of the
1263@code{@value{DIRPREFIX}rate_monotonic_period} directive.  More
1264specifically, the (ticks_)since_last_period value contains the elapsed time
1265which has occurred since the last invocation of the
1266@code{@value{DIRPREFIX}rate_monotonic_period} directive and the
1267(ticks_)executed_since_last_period contains how much processor time the
1268owning task has consumed since the invocation of the
1269@code{@value{DIRPREFIX}rate_monotonic_period} directive.
1270
1271@subheading NOTES:
1272
1273This directive will not cause the running task to be preempted.
1274
1275@c
1276@c
1277@c
1278@page
1279@subsection RATE_MONOTONIC_GET_STATISTICS - Obtain statistics from a period
1280
1281@cindex get statistics of period
1282@cindex obtain statistics of period
1283
1284@subheading CALLING SEQUENCE:
1285
1286@ifset is-C
1287@findex rtems_rate_monotonic_get_statistics
1288@example
1289rtems_status_code rtems_rate_monotonic_get_statistics(
1290  rtems_id                                id,
1291  rtems_rate_monotonic_period_statistics *statistics
1292);
1293@end example
1294@end ifset
1295
1296@ifset is-Ada
1297@example
1298NOT SUPPORTED FROM Ada BINDING
1299@end example
1300@end ifset
1301
1302@subheading DIRECTIVE STATUS CODES:
1303@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
1304@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
1305@code{@value{RPREFIX}INVALID_ADDRESS} - invalid address of statistics@*
1306
1307@subheading DESCRIPTION:
1308
1309This directive returns statistics information associated with
1310the rate monotonic period id in the following data @value{STRUCTURE}:
1311
1312@ifset is-C
1313@findex rtems_rate_monotonic_period_statistics
1314@example
1315typedef struct @{
1316  uint32_t     count;
1317  uint32_t     missed_count;
1318  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
1319    struct timespec min_cpu_time;
1320    struct timespec max_cpu_time;
1321    struct timespec total_cpu_time;
1322  #else
1323    uint32_t  min_cpu_time;
1324    uint32_t  max_cpu_time;
1325    uint32_t  total_cpu_time;
1326  #endif
1327  #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
1328    struct timespec min_wall_time;
1329    struct timespec max_wall_time;
1330    struct timespec total_wall_time;
1331  #else
1332    uint32_t  min_wall_time;
1333    uint32_t  max_wall_time;
1334    uint32_t  total_wall_time;
1335  #endif
1336@}  rtems_rate_monotonic_period_statistics;
1337@end example
1338@end ifset
1339
1340@ifset is-Ada
1341@example
1342NOT SUPPORTED FROM Ada BINDING
1343@end example
1344@end ifset
1345
1346This directive returns the current statistics information for
1347the period instance assocaited with @code{id}.  The information
1348returned is indicated by the structure above.
1349
1350@subheading NOTES:
1351
1352This directive will not cause the running task to be preempted.
1353
1354@c
1355@c
1356@c
1357@page
1358@subsection RATE_MONOTONIC_RESET_STATISTICS - Reset statistics for a period
1359
1360@cindex reset statistics of period
1361
1362@subheading CALLING SEQUENCE:
1363
1364@ifset is-C
1365@findex rtems_rate_monotonic_reset_statistics
1366@example
1367rtems_status_code rtems_rate_monotonic_reset_statistics(
1368  rtems_id  id
1369);
1370@end example
1371@end ifset
1372
1373@ifset is-Ada
1374@example
1375procedure Rate_Monotonic_Reset_Statistics (
1376   ID     : in     RTEMS.ID;
1377   Result :    out RTEMS.Status_Codes
1378);
1379@end example
1380@end ifset
1381
1382@subheading DIRECTIVE STATUS CODES:
1383@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
1384@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
1385
1386@subheading DESCRIPTION:
1387
1388This directive resets the statistics information associated with
1389this rate monotonic period instance.
1390
1391@subheading NOTES:
1392
1393This directive will not cause the running task to be preempted.
1394
1395@c
1396@c
1397@c
1398@page
1399@subsection RATE_MONOTONIC_RESET_ALL_STATISTICS - Reset statistics for all periods
1400
1401@cindex reset statistics of all periods
1402
1403@subheading CALLING SEQUENCE:
1404
1405@ifset is-C
1406@findex rtems_rate_monotonic_reset_all_statistics
1407@example
1408void rtems_rate_monotonic_reset_all_statistics(void);
1409@end example
1410@end ifset
1411
1412@ifset is-Ada
1413@example
1414procedure Rate_Monotonic_Reset_All_Statistics;
1415@end example
1416@end ifset
1417
1418@subheading DIRECTIVE STATUS CODES:
1419
1420NONE
1421
1422@subheading DESCRIPTION:
1423
1424This directive resets the statistics information associated with
1425all rate monotonic period instances.
1426
1427@subheading NOTES:
1428
1429This directive will not cause the running task to be preempted.
1430
1431@c
1432@c
1433@c
1434@page
1435@subsection RATE_MONOTONIC_REPORT_STATISTICS - Print period statistics report
1436
1437@cindex print period statistics report
1438@cindex period statistics report
1439
1440@subheading CALLING SEQUENCE:
1441
1442@ifset is-C
1443@findex rtems_rate_monotonic_report_statistics
1444@example
1445void rtems_rate_monotonic_report_statistics(void);
1446@end example
1447@end ifset
1448
1449@ifset is-Ada
1450@example
1451procedure Rate_Monotonic_Report_Statistics;
1452@end example
1453@end ifset
1454
1455@subheading DIRECTIVE STATUS CODES:
1456
1457NONE
1458
1459@subheading DESCRIPTION:
1460
1461This directive prints a report on all active periods which have
1462executed at least one period. The following is an example of the
1463output generated by this directive.
1464
1465@ifset is-C
1466@findex rtems_rate_monotonic_period_statistics
1467@example
1468   ID      OWNER   PERIODS  MISSED    CPU TIME    WALL TIME
1469                                    MIN/MAX/AVG  MIN/MAX/AVG
14700x42010001  TA1       502     0       0/1/0.99    0/0/0.00
14710x42010002  TA2       502     0       0/1/0.99    0/0/0.00
14720x42010003  TA3       501     0       0/1/0.99    0/0/0.00
14730x42010004  TA4       501     0       0/1/0.99    0/0/0.00
14740x42010005  TA5        10     0       0/1/0.90    0/0/0.00
1475@end example
1476@end ifset
1477
1478@subheading NOTES:
1479
1480This directive will not cause the running task to be preempted.
Note: See TracBrowser for help on using the repository browser.