@c
|
@c
|
@c COPYRIGHT (c) 1988-2002.
|
@c COPYRIGHT (c) 1988-2002.
|
@c On-Line Applications Research Corporation (OAR).
|
@c On-Line Applications Research Corporation (OAR).
|
@c All rights reserved.
|
@c All rights reserved.
|
@c
|
@c
|
@c rtmon.t,v 1.23 2002/03/27 17:35:15 joel Exp
|
@c rtmon.t,v 1.23 2002/03/27 17:35:15 joel Exp
|
@c
|
@c
|
|
|
@c
|
@c
|
@c Open Issues
|
@c Open Issues
|
@c - nicen up the tables
|
@c - nicen up the tables
|
@c - use math mode to print formulas
|
@c - use math mode to print formulas
|
@c
|
@c
|
|
|
@chapter Rate Monotonic Manager
|
@chapter Rate Monotonic Manager
|
|
|
@cindex rate mononitonic tasks
|
@cindex rate mononitonic tasks
|
@cindex periodic tasks
|
@cindex periodic tasks
|
|
|
@section Introduction
|
@section Introduction
|
|
|
The rate monotonic manager provides facilities to
|
The rate monotonic manager provides facilities to
|
implement tasks which execute in a periodic fashion. The
|
implement tasks which execute in a periodic fashion. The
|
directives provided by the rate monotonic manager are:
|
directives provided by the rate monotonic manager are:
|
|
|
@itemize @bullet
|
@itemize @bullet
|
@item @code{@value{DIRPREFIX}rate_monotonic_create} - Create a rate monotonic period
|
@item @code{@value{DIRPREFIX}rate_monotonic_create} - Create a rate monotonic period
|
@item @code{@value{DIRPREFIX}rate_monotonic_ident} - Get ID of a period
|
@item @code{@value{DIRPREFIX}rate_monotonic_ident} - Get ID of a period
|
@item @code{@value{DIRPREFIX}rate_monotonic_cancel} - Cancel a period
|
@item @code{@value{DIRPREFIX}rate_monotonic_cancel} - Cancel a period
|
@item @code{@value{DIRPREFIX}rate_monotonic_delete} - Delete a rate monotonic period
|
@item @code{@value{DIRPREFIX}rate_monotonic_delete} - Delete a rate monotonic period
|
@item @code{@value{DIRPREFIX}rate_monotonic_period} - Conclude current/Start next period
|
@item @code{@value{DIRPREFIX}rate_monotonic_period} - Conclude current/Start next period
|
@item @code{@value{DIRPREFIX}rate_monotonic_get_status} - Obtain status information on period
|
@item @code{@value{DIRPREFIX}rate_monotonic_get_status} - Obtain status information on period
|
@end itemize
|
@end itemize
|
|
|
@section Background
|
@section Background
|
|
|
The rate monotonic manager provides facilities to
|
The rate monotonic manager provides facilities to
|
manage the execution of periodic tasks. This manager was
|
manage the execution of periodic tasks. This manager was
|
designed to support application designers who utilize the Rate
|
designed to support application designers who utilize the Rate
|
Monotonic Scheduling Algorithm (RMS) to ensure that their
|
Monotonic Scheduling Algorithm (RMS) to ensure that their
|
periodic tasks will meet their deadlines, even under transient
|
periodic tasks will meet their deadlines, even under transient
|
overload conditions. Although designed for hard real-time
|
overload conditions. Although designed for hard real-time
|
systems, the services provided by the rate monotonic manager may
|
systems, the services provided by the rate monotonic manager may
|
be used by any application which requires periodic tasks.
|
be used by any application which requires periodic tasks.
|
|
|
@subsection Rate Monotonic Manager Required Support
|
@subsection Rate Monotonic Manager Required Support
|
|
|
A clock tick is required to support the functionality provided by this manager.
|
A clock tick is required to support the functionality provided by this manager.
|
|
|
@subsection Rate Monotonic Manager Definitions
|
@subsection Rate Monotonic Manager Definitions
|
|
|
@cindex periodic task, definition
|
@cindex periodic task, definition
|
|
|
A periodic task is one which must be executed at a
|
A periodic task is one which must be executed at a
|
regular interval. The interval between successive iterations of
|
regular interval. The interval between successive iterations of
|
the task is referred to as its period. Periodic tasks can be
|
the task is referred to as its period. Periodic tasks can be
|
characterized by the length of their period and execution time.
|
characterized by the length of their period and execution time.
|
The period and execution time of a task can be used to determine
|
The period and execution time of a task can be used to determine
|
the processor utilization for that task. Processor utilization
|
the processor utilization for that task. Processor utilization
|
is the percentage of processor time used and can be calculated
|
is the percentage of processor time used and can be calculated
|
on a per-task or system-wide basis. Typically, the task's
|
on a per-task or system-wide basis. Typically, the task's
|
worst-case execution time will be less than its period. For
|
worst-case execution time will be less than its period. For
|
example, a periodic task's requirements may state that it should
|
example, a periodic task's requirements may state that it should
|
execute for 10 milliseconds every 100 milliseconds. Although
|
execute for 10 milliseconds every 100 milliseconds. Although
|
the execution time may be the average, worst, or best case, the
|
the execution time may be the average, worst, or best case, the
|
worst-case execution time is more appropriate for use when
|
worst-case execution time is more appropriate for use when
|
analyzing system behavior under transient overload conditions.
|
analyzing system behavior under transient overload conditions.
|
|
|
@cindex aperiodic task, definition
|
@cindex aperiodic task, definition
|
|
|
In contrast, an aperiodic task executes at irregular
|
In contrast, an aperiodic task executes at irregular
|
intervals and has only a soft deadline. In other words, the
|
intervals and has only a soft deadline. In other words, the
|
deadlines for aperiodic tasks are not rigid, but adequate
|
deadlines for aperiodic tasks are not rigid, but adequate
|
response times are desirable. For example, an aperiodic task
|
response times are desirable. For example, an aperiodic task
|
may process user input from a terminal.
|
may process user input from a terminal.
|
|
|
@cindex sporadic task, definition
|
@cindex sporadic task, definition
|
|
|
Finally, a sporadic task is an aperiodic task with a
|
Finally, a sporadic task is an aperiodic task with a
|
hard deadline and minimum interarrival time. The minimum
|
hard deadline and minimum interarrival time. The minimum
|
interarrival time is the minimum period of time which exists
|
interarrival time is the minimum period of time which exists
|
between successive iterations of the task. For example, a
|
between successive iterations of the task. For example, a
|
sporadic task could be used to process the pressing of a fire
|
sporadic task could be used to process the pressing of a fire
|
button on a joystick. The mechanical action of the fire button
|
button on a joystick. The mechanical action of the fire button
|
ensures a minimum time period between successive activations,
|
ensures a minimum time period between successive activations,
|
but the missile must be launched by a hard deadline.
|
but the missile must be launched by a hard deadline.
|
|
|
@subsection Rate Monotonic Scheduling Algorithm
|
@subsection Rate Monotonic Scheduling Algorithm
|
|
|
@cindex Rate Monotonic Scheduling Algorithm, definition
|
@cindex Rate Monotonic Scheduling Algorithm, definition
|
@cindex RMS Algorithm, definition
|
@cindex RMS Algorithm, definition
|
|
|
The Rate Monotonic Scheduling Algorithm (RMS) is
|
The Rate Monotonic Scheduling Algorithm (RMS) is
|
important to real-time systems designers because it allows one
|
important to real-time systems designers because it allows one
|
to guarantee that a set of tasks is schedulable. A set of tasks
|
to guarantee that a set of tasks is schedulable. A set of tasks
|
is said to be schedulable if all of the tasks can meet their
|
is said to be schedulable if all of the tasks can meet their
|
deadlines. RMS provides a set of rules which can be used to
|
deadlines. RMS provides a set of rules which can be used to
|
perform a guaranteed schedulability analysis for a task set.
|
perform a guaranteed schedulability analysis for a task set.
|
This analysis determines whether a task set is schedulable under
|
This analysis determines whether a task set is schedulable under
|
worst-case conditions and emphasizes the predictability of the
|
worst-case conditions and emphasizes the predictability of the
|
system's behavior. It has been proven that:
|
system's behavior. It has been proven that:
|
|
|
@itemize @code{ }
|
@itemize @code{ }
|
@b{RMS is an optimal static priority algorithm for
|
@b{RMS is an optimal static priority algorithm for
|
scheduling independent, preemptible, periodic tasks
|
scheduling independent, preemptible, periodic tasks
|
on a single processor.}
|
on a single processor.}
|
@end itemize
|
@end itemize
|
|
|
RMS is optimal in the sense that if a set of tasks
|
RMS is optimal in the sense that if a set of tasks
|
can be scheduled by any static priority algorithm, then RMS will
|
can be scheduled by any static priority algorithm, then RMS will
|
be able to schedule that task set. RMS bases it schedulability
|
be able to schedule that task set. RMS bases it schedulability
|
analysis on the processor utilization level below which all
|
analysis on the processor utilization level below which all
|
deadlines can be met.
|
deadlines can be met.
|
|
|
RMS calls for the static assignment of task
|
RMS calls for the static assignment of task
|
priorities based upon their period. The shorter a task's
|
priorities based upon their period. The shorter a task's
|
period, the higher its priority. For example, a task with a 1
|
period, the higher its priority. For example, a task with a 1
|
millisecond period has higher priority than a task with a 100
|
millisecond period has higher priority than a task with a 100
|
millisecond period. If two tasks have the same period, then RMS
|
millisecond period. If two tasks have the same period, then RMS
|
does not distinguish between the tasks. However, RTEMS
|
does not distinguish between the tasks. However, RTEMS
|
specifies that when given tasks of equal priority, the task
|
specifies that when given tasks of equal priority, the task
|
which has been ready longest will execute first. RMS's priority
|
which has been ready longest will execute first. RMS's priority
|
assignment scheme does not provide one with exact numeric values
|
assignment scheme does not provide one with exact numeric values
|
for task priorities. For example, consider the following task
|
for task priorities. For example, consider the following task
|
set and priority assignments:
|
set and priority assignments:
|
|
|
@ifset use-ascii
|
@ifset use-ascii
|
@example
|
@example
|
@group
|
@group
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
| Task | Period | Priority |
|
| Task | Period | Priority |
|
| | (in milliseconds) | |
|
| | (in milliseconds) | |
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
| 1 | 100 | Low |
|
| 1 | 100 | Low |
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
| 2 | 50 | Medium |
|
| 2 | 50 | Medium |
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
| 3 | 50 | Medium |
|
| 3 | 50 | Medium |
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
| 4 | 25 | High |
|
| 4 | 25 | High |
|
+--------------------+---------------------+---------------------+
|
+--------------------+---------------------+---------------------+
|
@end group
|
@end group
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset use-tex
|
@ifset use-tex
|
@sp 1
|
@sp 1
|
@tex
|
@tex
|
\centerline{\vbox{\offinterlineskip\halign{
|
\centerline{\vbox{\offinterlineskip\halign{
|
\vrule\strut#&
|
\vrule\strut#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.25in{\enskip\hfil#\hfil}&
|
\hbox to 1.25in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.25in{\enskip\hfil#\hfil}&
|
\hbox to 1.25in{\enskip\hfil#\hfil}&
|
\vrule#\cr\noalign{\hrule}
|
\vrule#\cr\noalign{\hrule}
|
&\bf Task&& \bf Period && \bf Priority &\cr
|
&\bf Task&& \bf Period && \bf Priority &\cr
|
& && \bf (in milliseconds) && &\cr\noalign{\hrule}
|
& && \bf (in milliseconds) && &\cr\noalign{\hrule}
|
& 1 && 100 && Low &\cr\noalign{\hrule}
|
& 1 && 100 && Low &\cr\noalign{\hrule}
|
& 2 && 50 && Medium &\cr\noalign{\hrule}
|
& 2 && 50 && Medium &\cr\noalign{\hrule}
|
& 3 && 50 && Medium &\cr\noalign{\hrule}
|
& 3 && 50 && Medium &\cr\noalign{\hrule}
|
& 4 && 25 && High &\cr\noalign{\hrule}
|
& 4 && 25 && High &\cr\noalign{\hrule}
|
}}\hfil}
|
}}\hfil}
|
@end tex
|
@end tex
|
@end ifset
|
@end ifset
|
|
|
@ifset use-html
|
@ifset use-html
|
@html
|
@html
|
|
|
Task |
Task |
Period (in milliseconds) |
|
Period (in milliseconds) |
|
Priority |
|
|
Priority |
|
|
1 |
1 |
100 |
|
100 |
|
Low |
|
|
Low |
|
|
2 |
2 |
50 |
|
50 |
|
Medium |
|
|
Medium |
|
|
3 |
3 |
50 |
|
50 |
|
Medium |
|
|
Medium |
|
|
4 |
4 |
25 |
|
25 |
|
High |
|
|
High |
|
|
|
|
|
|
|
|
@end html
|
@end html
|
@end ifset
|
@end ifset
|
|
|
RMS only calls for task 1 to have the lowest
|
RMS only calls for task 1 to have the lowest
|
priority, task 4 to have the highest priority, and tasks 2 and 3
|
priority, task 4 to have the highest priority, and tasks 2 and 3
|
to have an equal priority between that of tasks 1 and 4. The
|
to have an equal priority between that of tasks 1 and 4. The
|
actual RTEMS priorities assigned to the tasks must only adhere
|
actual RTEMS priorities assigned to the tasks must only adhere
|
to those guidelines.
|
to those guidelines.
|
|
|
Many applications have tasks with both hard and soft
|
Many applications have tasks with both hard and soft
|
deadlines. The tasks with hard deadlines are typically referred
|
deadlines. The tasks with hard deadlines are typically referred
|
to as the critical task set, with the soft deadline tasks being
|
to as the critical task set, with the soft deadline tasks being
|
the non-critical task set. The critical task set can be
|
the non-critical task set. The critical task set can be
|
scheduled using RMS, with the non-critical tasks not executing
|
scheduled using RMS, with the non-critical tasks not executing
|
under transient overload, by simply assigning priorities such
|
under transient overload, by simply assigning priorities such
|
that the lowest priority critical task (i.e. longest period) has
|
that the lowest priority critical task (i.e. longest period) has
|
a higher priority than the highest priority non-critical task.
|
a higher priority than the highest priority non-critical task.
|
Although RMS may be used to assign priorities to the
|
Although RMS may be used to assign priorities to the
|
non-critical tasks, it is not necessary. In this instance,
|
non-critical tasks, it is not necessary. In this instance,
|
schedulability is only guaranteed for the critical task set.
|
schedulability is only guaranteed for the critical task set.
|
|
|
@subsection Schedulability Analysis
|
@subsection Schedulability Analysis
|
|
|
@cindex RMS schedulability analysis
|
@cindex RMS schedulability analysis
|
|
|
RMS allows application designers to ensure that tasks
|
RMS allows application designers to ensure that tasks
|
can meet all deadlines, even under transient overload, without
|
can meet all deadlines, even under transient overload, without
|
knowing exactly when any given task will execute by applying
|
knowing exactly when any given task will execute by applying
|
proven schedulability analysis rules.
|
proven schedulability analysis rules.
|
|
|
@lowersections
|
@lowersections
|
|
|
@subsection Assumptions
|
@subsection Assumptions
|
|
|
The schedulability analysis rules for RMS were
|
The schedulability analysis rules for RMS were
|
developed based on the following assumptions:
|
developed based on the following assumptions:
|
|
|
|
|
@itemize @bullet
|
@itemize @bullet
|
@item The requests for all tasks for which hard deadlines
|
@item The requests for all tasks for which hard deadlines
|
exist are periodic, with a constant interval between requests.
|
exist are periodic, with a constant interval between requests.
|
|
|
@item Each task must complete before the next request for it
|
@item Each task must complete before the next request for it
|
occurs.
|
occurs.
|
|
|
@item The tasks are independent in that a task does not depend
|
@item The tasks are independent in that a task does not depend
|
on the initiation or completion of requests for other tasks.
|
on the initiation or completion of requests for other tasks.
|
|
|
@item The execution time for each task without preemption or
|
@item The execution time for each task without preemption or
|
interruption is constant and does not vary.
|
interruption is constant and does not vary.
|
|
|
@item Any non-periodic tasks in the system are special. These
|
@item Any non-periodic tasks in the system are special. These
|
tasks displace periodic tasks while executing and do not have
|
tasks displace periodic tasks while executing and do not have
|
hard, critical deadlines.
|
hard, critical deadlines.
|
@end itemize
|
@end itemize
|
|
|
Once the basic schedulability analysis is understood,
|
Once the basic schedulability analysis is understood,
|
some of the above assumptions can be relaxed and the
|
some of the above assumptions can be relaxed and the
|
side-effects accounted for.
|
side-effects accounted for.
|
|
|
@subsection Processor Utilization Rule
|
@subsection Processor Utilization Rule
|
|
|
@cindex RMS Processor Utilization Rule
|
@cindex RMS Processor Utilization Rule
|
|
|
The Processor Utilization Rule requires that
|
The Processor Utilization Rule requires that
|
processor utilization be calculated based upon the period and
|
processor utilization be calculated based upon the period and
|
execution time of each task. The fraction of processor time
|
execution time of each task. The fraction of processor time
|
spent executing task index is Time(index) / Period(index). The
|
spent executing task index is Time(index) / Period(index). The
|
processor utilization can be calculated as follows:
|
processor utilization can be calculated as follows:
|
|
|
@example
|
@example
|
@group
|
@group
|
Utilization = 0
|
Utilization = 0
|
|
|
for index = 1 to maximum_tasks
|
for index = 1 to maximum_tasks
|
Utilization = Utilization + (Time(index)/Period(index))
|
Utilization = Utilization + (Time(index)/Period(index))
|
@end group
|
@end group
|
@end example
|
@end example
|
|
|
To ensure schedulability even under transient
|
To ensure schedulability even under transient
|
overload, the processor utilization must adhere to the following
|
overload, the processor utilization must adhere to the following
|
rule:
|
rule:
|
|
|
@example
|
@example
|
Utilization = maximum_tasks * (2(1/maximum_tasks) - 1)
|
Utilization = maximum_tasks * (2(1/maximum_tasks) - 1)
|
@end example
|
@end example
|
|
|
As the number of tasks increases, the above formula
|
As the number of tasks increases, the above formula
|
approaches ln(2) for a worst-case utilization factor of
|
approaches ln(2) for a worst-case utilization factor of
|
approximately 0.693. Many tasks sets can be scheduled with a
|
approximately 0.693. Many tasks sets can be scheduled with a
|
greater utilization factor. In fact, the average processor
|
greater utilization factor. In fact, the average processor
|
utilization threshold for a randomly generated task set is
|
utilization threshold for a randomly generated task set is
|
approximately 0.88.
|
approximately 0.88.
|
|
|
@subsection Processor Utilization Rule Example
|
@subsection Processor Utilization Rule Example
|
|
|
This example illustrates the application of the
|
This example illustrates the application of the
|
Processor Utilization Rule to an application with three critical
|
Processor Utilization Rule to an application with three critical
|
periodic tasks. The following table details the RMS priority,
|
periodic tasks. The following table details the RMS priority,
|
period, execution time, and processor utilization for each task:
|
period, execution time, and processor utilization for each task:
|
|
|
@ifset use-ascii
|
@ifset use-ascii
|
@example
|
@example
|
@group
|
@group
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| Task | RMS | Period | Execution | Processor |
|
| Task | RMS | Period | Execution | Processor |
|
| | Priority | | Time | Utilization |
|
| | Priority | | Time | Utilization |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 1 | High | 100 | 15 | 0.15 |
|
| 1 | High | 100 | 15 | 0.15 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 2 | Medium | 200 | 50 | 0.25 |
|
| 2 | Medium | 200 | 50 | 0.25 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 3 | Low | 300 | 100 | 0.33 |
|
| 3 | Low | 300 | 100 | 0.33 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
@end group
|
@end group
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset use-tex
|
@ifset use-tex
|
@sp 1
|
@sp 1
|
@tex
|
@tex
|
\centerline{\vbox{\offinterlineskip\halign{
|
\centerline{\vbox{\offinterlineskip\halign{
|
\vrule\strut#&
|
\vrule\strut#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\vrule#\cr\noalign{\hrule}
|
\vrule#\cr\noalign{\hrule}
|
&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
|
&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
|
& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
|
& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
|
& 1 && High && 100 && 15 && 0.15 &\cr\noalign{\hrule}
|
& 1 && High && 100 && 15 && 0.15 &\cr\noalign{\hrule}
|
& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
|
& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
|
& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
|
& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
|
}}\hfil}
|
}}\hfil}
|
@end tex
|
@end tex
|
@end ifset
|
@end ifset
|
|
|
@ifset use-html
|
@ifset use-html
|
@html
|
@html
|
|
|
Task |
Task |
RMS Priority |
|
RMS Priority |
|
Period |
|
Period |
|
Execution Time |
|
Execution Time |
|
Processor Utilization |
|
|
Processor Utilization |
|
|
1 |
1 |
High |
|
High |
|
100 |
|
100 |
|
15 |
|
15 |
|
0.15 |
|
|
0.15 |
|
|
2 |
2 |
Medium |
|
Medium |
|
200 |
|
200 |
|
50 |
|
50 |
|
0.25 |
|
|
0.25 |
|
|
3 |
3 |
Low |
|
Low |
|
300 |
|
300 |
|
100 |
|
100 |
|
0.33 |
|
|
0.33 |
|
|
|
|
|
|
|
|
@end html
|
@end html
|
@end ifset
|
@end ifset
|
|
|
The total processor utilization for this task set is
|
The total processor utilization for this task set is
|
0.73 which is below the upper bound of 3 * (2(1/3) - 1), or
|
0.73 which is below the upper bound of 3 * (2(1/3) - 1), or
|
0.779, imposed by the Processor Utilization Rule. Therefore,
|
0.779, imposed by the Processor Utilization Rule. Therefore,
|
this task set is guaranteed to be schedulable using RMS.
|
this task set is guaranteed to be schedulable using RMS.
|
|
|
@subsection First Deadline Rule
|
@subsection First Deadline Rule
|
|
|
@cindex RMS First Deadline Rule
|
@cindex RMS First Deadline Rule
|
|
|
If a given set of tasks do exceed the processor
|
If a given set of tasks do exceed the processor
|
utilization upper limit imposed by the Processor Utilization
|
utilization upper limit imposed by the Processor Utilization
|
Rule, they can still be guaranteed to meet all their deadlines
|
Rule, they can still be guaranteed to meet all their deadlines
|
by application of the First Deadline Rule. This rule can be
|
by application of the First Deadline Rule. This rule can be
|
stated as follows:
|
stated as follows:
|
|
|
For a given set of independent periodic tasks, if
|
For a given set of independent periodic tasks, if
|
each task meets its first deadline when all tasks are started at
|
each task meets its first deadline when all tasks are started at
|
the same time, then the deadlines will always be met for any
|
the same time, then the deadlines will always be met for any
|
combination of start times.
|
combination of start times.
|
|
|
A key point with this rule is that ALL periodic tasks
|
A key point with this rule is that ALL periodic tasks
|
are assumed to start at the exact same instant in time.
|
are assumed to start at the exact same instant in time.
|
Although this assumption may seem to be invalid, RTEMS makes it
|
Although this assumption may seem to be invalid, RTEMS makes it
|
quite easy to ensure. By having a non-preemptible user
|
quite easy to ensure. By having a non-preemptible user
|
initialization task, all application tasks, regardless of
|
initialization task, all application tasks, regardless of
|
priority, can be created and started before the initialization
|
priority, can be created and started before the initialization
|
deletes itself. This technique ensures that all tasks begin to
|
deletes itself. This technique ensures that all tasks begin to
|
compete for execution time at the same instant -- when the user
|
compete for execution time at the same instant -- when the user
|
initialization task deletes itself.
|
initialization task deletes itself.
|
|
|
@subsection First Deadline Rule Example
|
@subsection First Deadline Rule Example
|
|
|
The First Deadline Rule can ensure schedulability
|
The First Deadline Rule can ensure schedulability
|
even when the Processor Utilization Rule fails. The example
|
even when the Processor Utilization Rule fails. The example
|
below is a modification of the Processor Utilization Rule
|
below is a modification of the Processor Utilization Rule
|
example where task execution time has been increased from 15 to
|
example where task execution time has been increased from 15 to
|
25 units. The following table details the RMS priority, period,
|
25 units. The following table details the RMS priority, period,
|
execution time, and processor utilization for each task:
|
execution time, and processor utilization for each task:
|
|
|
@ifset use-ascii
|
@ifset use-ascii
|
@example
|
@example
|
@group
|
@group
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| Task | RMS | Period | Execution | Processor |
|
| Task | RMS | Period | Execution | Processor |
|
| | Priority | | Time | Utilization |
|
| | Priority | | Time | Utilization |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 1 | High | 100 | 25 | 0.25 |
|
| 1 | High | 100 | 25 | 0.25 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 2 | Medium | 200 | 50 | 0.25 |
|
| 2 | Medium | 200 | 50 | 0.25 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
| 3 | Low | 300 | 100 | 0.33 |
|
| 3 | Low | 300 | 100 | 0.33 |
|
+------------+----------+--------+-----------+-------------+
|
+------------+----------+--------+-----------+-------------+
|
@end group
|
@end group
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset use-tex
|
@ifset use-tex
|
@sp 1
|
@sp 1
|
@tex
|
@tex
|
\centerline{\vbox{\offinterlineskip\halign{
|
\centerline{\vbox{\offinterlineskip\halign{
|
\vrule\strut#&
|
\vrule\strut#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\vrule#\cr\noalign{\hrule}
|
\vrule#\cr\noalign{\hrule}
|
&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
|
&\bf Task&& \bf RMS && \bf Period && \bf Execution &&\bf Processor&\cr
|
& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
|
& && \bf Priority && &&\bf Time &&\bf Utilization &\cr\noalign{\hrule}
|
& 1 && High && 100 && 25 && 0.25 &\cr\noalign{\hrule}
|
& 1 && High && 100 && 25 && 0.25 &\cr\noalign{\hrule}
|
& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
|
& 2 && Medium && 200 && 50 && 0.25 &\cr\noalign{\hrule}
|
& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
|
& 3 && Low && 300 && 100 && 0.33 &\cr\noalign{\hrule}
|
}}\hfil}
|
}}\hfil}
|
@end tex
|
@end tex
|
@end ifset
|
@end ifset
|
|
|
@ifset use-html
|
@ifset use-html
|
@html
|
@html
|
|
|
Task |
Task |
RMS Priority |
|
RMS Priority |
|
Period |
|
Period |
|
Execution Time |
|
Execution Time |
|
Processor Utilization |
|
|
Processor Utilization |
|
|
1 |
1 |
High |
|
High |
|
100 |
|
100 |
|
25 |
|
25 |
|
0.25 |
|
|
0.25 |
|
|
2 |
2 |
Medium |
|
Medium |
|
200 |
|
200 |
|
50 |
|
50 |
|
0.25 |
|
|
0.25 |
|
|
3 |
3 |
Low |
|
Low |
|
300 |
|
300 |
|
100 |
|
100 |
|
0.33 |
|
|
0.33 |
|
|
|
|
|
|
|
|
@end html
|
@end html
|
@end ifset
|
@end ifset
|
|
|
The total processor utilization for the modified task
|
The total processor utilization for the modified task
|
set is 0.83 which is above the upper bound of 3 * (2(1/3) - 1),
|
set is 0.83 which is above the upper bound of 3 * (2(1/3) - 1),
|
or 0.779, imposed by the Processor Utilization Rule. Therefore,
|
or 0.779, imposed by the Processor Utilization Rule. Therefore,
|
this task set is not guaranteed to be schedulable using RMS.
|
this task set is not guaranteed to be schedulable using RMS.
|
However, the First Deadline Rule can guarantee the
|
However, the First Deadline Rule can guarantee the
|
schedulability of this task set. This rule calls for one to
|
schedulability of this task set. This rule calls for one to
|
examine each occurrence of deadline until either all tasks have
|
examine each occurrence of deadline until either all tasks have
|
met their deadline or one task failed to meet its first
|
met their deadline or one task failed to meet its first
|
deadline. The following table details the time of each deadline
|
deadline. The following table details the time of each deadline
|
occurrence, the maximum number of times each task may have run,
|
occurrence, the maximum number of times each task may have run,
|
the total execution time, and whether all the deadlines have
|
the total execution time, and whether all the deadlines have
|
been met.
|
been met.
|
|
|
@ifset use-ascii
|
@ifset use-ascii
|
@example
|
@example
|
@group
|
@group
|
+----------+------+------+------+----------------------+---------------+
|
+----------+------+------+------+----------------------+---------------+
|
| Deadline | Task | Task | Task | Total | All Deadlines |
|
| Deadline | Task | Task | Task | Total | All Deadlines |
|
| Time | 1 | 2 | 3 | Execution Time | Met? |
|
| Time | 1 | 2 | 3 | Execution Time | Met? |
|
+----------+------+------+------+----------------------+---------------+
|
+----------+------+------+------+----------------------+---------------+
|
| 100 | 1 | 1 | 1 | 25 + 50 + 100 = 175 | NO |
|
| 100 | 1 | 1 | 1 | 25 + 50 + 100 = 175 | NO |
|
+----------+------+------+------+----------------------+---------------+
|
+----------+------+------+------+----------------------+---------------+
|
| 200 | 2 | 1 | 1 | 50 + 50 + 100 = 200 | YES |
|
| 200 | 2 | 1 | 1 | 50 + 50 + 100 = 200 | YES |
|
+----------+------+------+------+----------------------+---------------+
|
+----------+------+------+------+----------------------+---------------+
|
@end group
|
@end group
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset use-tex
|
@ifset use-tex
|
@sp 1
|
@sp 1
|
@tex
|
@tex
|
\centerline{\vbox{\offinterlineskip\halign{
|
\centerline{\vbox{\offinterlineskip\halign{
|
\vrule\strut#&
|
\vrule\strut#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\hbox to 0.75in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 2.00in{\enskip\hfil#\hfil}&
|
\hbox to 2.00in{\enskip\hfil#\hfil}&
|
\vrule#&
|
\vrule#&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\hbox to 1.00in{\enskip\hfil#\hfil}&
|
\vrule#\cr\noalign{\hrule}
|
\vrule#\cr\noalign{\hrule}
|
&\bf Deadline&& \bf Task &&\bf Task&&\bf Task&&\bf Total &&\bf All Deadlines &\cr
|
&\bf Deadline&& \bf Task &&\bf Task&&\bf Task&&\bf Total &&\bf All Deadlines &\cr
|
&\bf Time && \bf 1 &&\bf 2 &&\bf 3 &&\bf Execution Time &&\bf Net?&\cr\noalign{\hrule}
|
&\bf Time && \bf 1 &&\bf 2 &&\bf 3 &&\bf Execution Time &&\bf Net?&\cr\noalign{\hrule}
|
& 100&& 1 && 1 && 1 && 25 + 50 + 100 = 175 && NO &\cr\noalign{\hrule}
|
& 100&& 1 && 1 && 1 && 25 + 50 + 100 = 175 && NO &\cr\noalign{\hrule}
|
& 200&& 2 && 1 && 1 && 50 + 50 + 100 = 200 && YES &\cr\noalign{\hrule}
|
& 200&& 2 && 1 && 1 && 50 + 50 + 100 = 200 && YES &\cr\noalign{\hrule}
|
}}\hfil}
|
}}\hfil}
|
@end tex
|
@end tex
|
@end ifset
|
@end ifset
|
|
|
@ifset use-html
|
@ifset use-html
|
@html
|
@html
|
|
|
Deadline Time |
Deadline Time |
Task 1 |
|
Task 1 |
|
Task 2 |
|
Task 2 |
|
Task 3 |
|
Task 3 |
|
Total Execution Time |
|
Total Execution Time |
|
All Deadlines Met? |
|
|
All Deadlines Met? |
|
|
100 |
100 |
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
25 + 50 + 100 = 175 |
|
25 + 50 + 100 = 175 |
|
NO |
|
|
NO |
|
|
200 |
200 |
2 |
|
2 |
|
1 |
|
1 |
|
1 |
|
1 |
|
50 + 50 + 100 = 175 |
|
50 + 50 + 100 = 175 |
|
YES |
|
|
YES |
|
|
|
|
|
|
|
|
@end html
|
@end html
|
@end ifset
|
@end ifset
|
|
|
The key to this analysis is to recognize when each
|
The key to this analysis is to recognize when each
|
task will execute. For example at time 100, task 1 must have
|
task will execute. For example at time 100, task 1 must have
|
met its first deadline, but tasks 2 and 3 may also have begun
|
met its first deadline, but tasks 2 and 3 may also have begun
|
execution. In this example, at time 100 tasks 1 and 2 have
|
execution. In this example, at time 100 tasks 1 and 2 have
|
completed execution and thus have met their first deadline.
|
completed execution and thus have met their first deadline.
|
Tasks 1 and 2 have used (25 + 50) = 75 time units, leaving (100
|
Tasks 1 and 2 have used (25 + 50) = 75 time units, leaving (100
|
- 75) = 25 time units for task 3 to begin. Because task 3 takes
|
- 75) = 25 time units for task 3 to begin. Because task 3 takes
|
100 ticks to execute, it will not have completed execution at
|
100 ticks to execute, it will not have completed execution at
|
time 100. Thus at time 100, all of the tasks except task 3 have
|
time 100. Thus at time 100, all of the tasks except task 3 have
|
met their first deadline.
|
met their first deadline.
|
|
|
At time 200, task 1 must have met its second deadline
|
At time 200, task 1 must have met its second deadline
|
and task 2 its first deadline. As a result, of the first 200
|
and task 2 its first deadline. As a result, of the first 200
|
time units, task 1 uses (2 * 25) = 50 and task 2 uses 50,
|
time units, task 1 uses (2 * 25) = 50 and task 2 uses 50,
|
leaving (200 - 100) time units for task 3. Task 3 requires 100
|
leaving (200 - 100) time units for task 3. Task 3 requires 100
|
time units to execute, thus it will have completed execution at
|
time units to execute, thus it will have completed execution at
|
time 200. Thus, all of the tasks have met their first deadlines
|
time 200. Thus, all of the tasks have met their first deadlines
|
at time 200, and the task set is schedulable using the First
|
at time 200, and the task set is schedulable using the First
|
Deadline Rule.
|
Deadline Rule.
|
|
|
@subsection Relaxation of Assumptions
|
@subsection Relaxation of Assumptions
|
|
|
The assumptions used to develop the RMS
|
The assumptions used to develop the RMS
|
schedulability rules are uncommon in most real-time systems.
|
schedulability rules are uncommon in most real-time systems.
|
For example, it was assumed that tasks have constant unvarying
|
For example, it was assumed that tasks have constant unvarying
|
execution time. It is possible to relax this assumption, simply
|
execution time. It is possible to relax this assumption, simply
|
by using the worst-case execution time of each task.
|
by using the worst-case execution time of each task.
|
|
|
Another assumption is that the tasks are independent.
|
Another assumption is that the tasks are independent.
|
This means that the tasks do not wait for one another or
|
This means that the tasks do not wait for one another or
|
contend for resources. This assumption can be relaxed by
|
contend for resources. This assumption can be relaxed by
|
accounting for the amount of time a task spends waiting to
|
accounting for the amount of time a task spends waiting to
|
acquire resources. Similarly, each task's execution time must
|
acquire resources. Similarly, each task's execution time must
|
account for any I/O performed and any RTEMS directive calls.
|
account for any I/O performed and any RTEMS directive calls.
|
|
|
In addition, the assumptions did not account for the
|
In addition, the assumptions did not account for the
|
time spent executing interrupt service routines. This can be
|
time spent executing interrupt service routines. This can be
|
accounted for by including all the processor utilization by
|
accounted for by including all the processor utilization by
|
interrupt service routines in the utilization calculation.
|
interrupt service routines in the utilization calculation.
|
Similarly, one should also account for the impact of delays in
|
Similarly, one should also account for the impact of delays in
|
accessing local memory caused by direct memory access and other
|
accessing local memory caused by direct memory access and other
|
processors accessing local dual-ported memory.
|
processors accessing local dual-ported memory.
|
|
|
The assumption that nonperiodic tasks are used only
|
The assumption that nonperiodic tasks are used only
|
for initialization or failure-recovery can be relaxed by placing
|
for initialization or failure-recovery can be relaxed by placing
|
all periodic tasks in the critical task set. This task set can
|
all periodic tasks in the critical task set. This task set can
|
be scheduled and analyzed using RMS. All nonperiodic tasks are
|
be scheduled and analyzed using RMS. All nonperiodic tasks are
|
placed in the non-critical task set. Although the critical task
|
placed in the non-critical task set. Although the critical task
|
set can be guaranteed to execute even under transient overload,
|
set can be guaranteed to execute even under transient overload,
|
the non-critical task set is not guaranteed to execute.
|
the non-critical task set is not guaranteed to execute.
|
|
|
In conclusion, the application designer must be fully
|
In conclusion, the application designer must be fully
|
cognizant of the system and its run-time behavior when
|
cognizant of the system and its run-time behavior when
|
performing schedulability analysis for a system using RMS.
|
performing schedulability analysis for a system using RMS.
|
Every hardware and software factor which impacts the execution
|
Every hardware and software factor which impacts the execution
|
time of each task must be accounted for in the schedulability
|
time of each task must be accounted for in the schedulability
|
analysis.
|
analysis.
|
|
|
@subsection Further Reading
|
@subsection Further Reading
|
|
|
For more information on Rate Monotonic Scheduling and
|
For more information on Rate Monotonic Scheduling and
|
its schedulability analysis, the reader is referred to the
|
its schedulability analysis, the reader is referred to the
|
following:
|
following:
|
|
|
@itemize @code{ }
|
@itemize @code{ }
|
@item @cite{C. L. Liu and J. W. Layland. "Scheduling Algorithms for
|
@item @cite{C. L. Liu and J. W. Layland. "Scheduling Algorithms for
|
Multiprogramming in a Hard Real Time Environment." @b{Journal of
|
Multiprogramming in a Hard Real Time Environment." @b{Journal of
|
the Association of Computing Machinery}. January 1973. pp. 46-61.}
|
the Association of Computing Machinery}. January 1973. pp. 46-61.}
|
|
|
@item @cite{John Lehoczky, Lui Sha, and Ye Ding. "The Rate Monotonic
|
@item @cite{John Lehoczky, Lui Sha, and Ye Ding. "The Rate Monotonic
|
Scheduling Algorithm: Exact Characterization and Average Case
|
Scheduling Algorithm: Exact Characterization and Average Case
|
Behavior." @b{IEEE Real-Time Systems Symposium}. 1989. pp. 166-171.}
|
Behavior." @b{IEEE Real-Time Systems Symposium}. 1989. pp. 166-171.}
|
|
|
@item @cite{Lui Sha and John Goodenough. "Real-Time Scheduling
|
@item @cite{Lui Sha and John Goodenough. "Real-Time Scheduling
|
Theory and Ada." @b{IEEE Computer}. April 1990. pp. 53-62.}
|
Theory and Ada." @b{IEEE Computer}. April 1990. pp. 53-62.}
|
|
|
@item @cite{Alan Burns. "Scheduling hard real-time systems: a
|
@item @cite{Alan Burns. "Scheduling hard real-time systems: a
|
review." @b{Software Engineering Journal}. May 1991. pp. 116-128.}
|
review." @b{Software Engineering Journal}. May 1991. pp. 116-128.}
|
@end itemize
|
@end itemize
|
|
|
@raisesections
|
@raisesections
|
|
|
@section Operations
|
@section Operations
|
|
|
@subsection Creating a Rate Monotonic Period
|
@subsection Creating a Rate Monotonic Period
|
|
|
The @code{@value{DIRPREFIX}rate_monotonic_create} directive creates a rate
|
The @code{@value{DIRPREFIX}rate_monotonic_create} directive creates a rate
|
monotonic period which is to be used by the calling task to
|
monotonic period which is to be used by the calling task to
|
delineate a period. RTEMS allocates a Period Control Block
|
delineate a period. RTEMS allocates a Period Control Block
|
(PCB) from the PCB free list. This data structure is used by
|
(PCB) from the PCB free list. This data structure is used by
|
RTEMS to manage the newly created rate monotonic period. RTEMS
|
RTEMS to manage the newly created rate monotonic period. RTEMS
|
returns a unique period ID to the application which is used by
|
returns a unique period ID to the application which is used by
|
other rate monotonic manager directives to access this rate
|
other rate monotonic manager directives to access this rate
|
monotonic period.
|
monotonic period.
|
|
|
@subsection Manipulating a Period
|
@subsection Manipulating a Period
|
|
|
The @code{@value{DIRPREFIX}rate_monotonic_period} directive is used to
|
The @code{@value{DIRPREFIX}rate_monotonic_period} directive is used to
|
establish and maintain periodic execution utilizing a previously
|
establish and maintain periodic execution utilizing a previously
|
created rate monotonic period. Once initiated by the
|
created rate monotonic period. Once initiated by the
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive, the period is
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive, the period is
|
said to run until it either expires or is reinitiated. The state of the rate
|
said to run until it either expires or is reinitiated. The state of the rate
|
monotonic period results in one of the following scenarios:
|
monotonic period results in one of the following scenarios:
|
|
|
@itemize @bullet
|
@itemize @bullet
|
@item If the rate monotonic period is running, the calling
|
@item If the rate monotonic period is running, the calling
|
task will be blocked for the remainder of the outstanding period
|
task will be blocked for the remainder of the outstanding period
|
and, upon completion of that period, the period will be
|
and, upon completion of that period, the period will be
|
reinitiated with the specified period.
|
reinitiated with the specified period.
|
|
|
@item If the rate monotonic period is not currently running
|
@item If the rate monotonic period is not currently running
|
and has not expired, it is initiated with a length of period
|
and has not expired, it is initiated with a length of period
|
ticks and the calling task returns immediately.
|
ticks and the calling task returns immediately.
|
|
|
@item If the rate monotonic period has expired before the task
|
@item If the rate monotonic period has expired before the task
|
invokes the @code{@value{DIRPREFIX}rate_monotonic_period} directive,
|
invokes the @code{@value{DIRPREFIX}rate_monotonic_period} directive,
|
the period will be initiated with a length of period ticks and the calling task
|
the period will be initiated with a length of period ticks and the calling task
|
returns immediately with a timeout error status.
|
returns immediately with a timeout error status.
|
|
|
@end itemize
|
@end itemize
|
|
|
@subsection Obtaining the Status of a Period
|
@subsection Obtaining the Status of a Period
|
|
|
If the @code{@value{DIRPREFIX}rate_monotonic_period} directive is invoked
|
If the @code{@value{DIRPREFIX}rate_monotonic_period} directive is invoked
|
with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the current
|
with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the current
|
state of the specified rate monotonic period will be returned. The following
|
state of the specified rate monotonic period will be returned. The following
|
table details the relationship between the period's status and
|
table details the relationship between the period's status and
|
the directive status code returned by the
|
the directive status code returned by the
|
@code{@value{DIRPREFIX}rate_monotonic_period}
|
@code{@value{DIRPREFIX}rate_monotonic_period}
|
directive:
|
directive:
|
|
|
@itemize @bullet
|
@itemize @bullet
|
@item @code{@value{RPREFIX}SUCCESSFUL} - period is running
|
@item @code{@value{RPREFIX}SUCCESSFUL} - period is running
|
|
|
@item @code{@value{RPREFIX}TIMEOUT} - period has expired
|
@item @code{@value{RPREFIX}TIMEOUT} - period has expired
|
|
|
@item @code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated
|
@item @code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated
|
@end itemize
|
@end itemize
|
|
|
Obtaining the status of a rate monotonic period does
|
Obtaining the status of a rate monotonic period does
|
not alter the state or length of that period.
|
not alter the state or length of that period.
|
|
|
@subsection Canceling a Period
|
@subsection Canceling a Period
|
|
|
The @code{@value{DIRPREFIX}rate_monotonic_cancel} directive is used to stop
|
The @code{@value{DIRPREFIX}rate_monotonic_cancel} directive is used to stop
|
the period maintained by the specified rate monotonic period.
|
the period maintained by the specified rate monotonic period.
|
The period is stopped and the rate monotonic period can be
|
The period is stopped and the rate monotonic period can be
|
reinitiated using the @code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
reinitiated using the @code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
|
|
@subsection Deleting a Rate Monotonic Period
|
@subsection Deleting a Rate Monotonic Period
|
|
|
The @code{@value{DIRPREFIX}rate_monotonic_delete} directive is used to delete
|
The @code{@value{DIRPREFIX}rate_monotonic_delete} directive is used to delete
|
a rate monotonic period. If the period is running and has not
|
a rate monotonic period. If the period is running and has not
|
expired, the period is automatically canceled. The rate
|
expired, the period is automatically canceled. The rate
|
monotonic period's control block is returned to the PCB free
|
monotonic period's control block is returned to the PCB free
|
list when it is deleted. A rate monotonic period can be deleted
|
list when it is deleted. A rate monotonic period can be deleted
|
by a task other than the task which created the period.
|
by a task other than the task which created the period.
|
|
|
@subsection Examples
|
@subsection Examples
|
|
|
The following sections illustrate common uses of rate
|
The following sections illustrate common uses of rate
|
monotonic periods to construct periodic tasks.
|
monotonic periods to construct periodic tasks.
|
|
|
@subsection Simple Periodic Task
|
@subsection Simple Periodic Task
|
|
|
This example consists of a single periodic task
|
This example consists of a single periodic task
|
which, after initialization, executes every 100 clock ticks.
|
which, after initialization, executes every 100 clock ticks.
|
|
|
@page
|
@page
|
@example
|
@example
|
rtems_task Periodic_task(rtems_task_argument arg)
|
rtems_task Periodic_task(rtems_task_argument arg)
|
@{
|
@{
|
rtems_name name;
|
rtems_name name;
|
rtems_id period;
|
rtems_id period;
|
rtems_status_code status;
|
rtems_status_code status;
|
|
|
name = rtems_build_name( 'P', 'E', 'R', 'D' );
|
name = rtems_build_name( 'P', 'E', 'R', 'D' );
|
|
|
status = rtems_rate_monotonic_create( name, &period );
|
status = rtems_rate_monotonic_create( name, &period );
|
if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
|
if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
|
printf( "rtems_monotonic_create failed with status of %d.\n", rc );
|
printf( "rtems_monotonic_create failed with status of %d.\n", rc );
|
exit( 1 );
|
exit( 1 );
|
@}
|
@}
|
|
|
|
|
while ( 1 ) @{
|
while ( 1 ) @{
|
if ( rtems_rate_monotonic_period( period, 100 ) == RTEMS_TIMEOUT )
|
if ( rtems_rate_monotonic_period( period, 100 ) == RTEMS_TIMEOUT )
|
break;
|
break;
|
|
|
/* Perform some periodic actions */
|
/* Perform some periodic actions */
|
@}
|
@}
|
|
|
/* missed period so delete period and SELF */
|
/* missed period so delete period and SELF */
|
|
|
status = rtems_rate_monotonic_delete( period );
|
status = rtems_rate_monotonic_delete( period );
|
if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
|
if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
|
printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
|
printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
|
exit( 1 );
|
exit( 1 );
|
@}
|
@}
|
|
|
status = rtems_task_delete( SELF ); /* should not return */
|
status = rtems_task_delete( SELF ); /* should not return */
|
printf( "rtems_task_delete returned with status of %d.\n", status );
|
printf( "rtems_task_delete returned with status of %d.\n", status );
|
exit( 1 );
|
exit( 1 );
|
@}
|
@}
|
@end example
|
@end example
|
|
|
|
|
The above task creates a rate monotonic period as
|
The above task creates a rate monotonic period as
|
part of its initialization. The first time the loop is
|
part of its initialization. The first time the loop is
|
executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
directive will initiate the period for 100 ticks and return
|
directive will initiate the period for 100 ticks and return
|
immediately. Subsequent invocations of the
|
immediately. Subsequent invocations of the
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive will result
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive will result
|
in the task blocking for the remainder of the 100 tick period.
|
in the task blocking for the remainder of the 100 tick period.
|
If, for any reason, the body of the loop takes more than 100
|
If, for any reason, the body of the loop takes more than 100
|
ticks to execute, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
ticks to execute, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
directive will return the @code{@value{RPREFIX}TIMEOUT} status.
|
directive will return the @code{@value{RPREFIX}TIMEOUT} status.
|
If the above task misses its deadline, it will delete the rate
|
If the above task misses its deadline, it will delete the rate
|
monotonic period and itself.
|
monotonic period and itself.
|
|
|
@subsection Task with Multiple Periods
|
@subsection Task with Multiple Periods
|
|
|
This example consists of a single periodic task
|
This example consists of a single periodic task
|
which, after initialization, performs two sets of actions every
|
which, after initialization, performs two sets of actions every
|
100 clock ticks. The first set of actions is performed in the
|
100 clock ticks. The first set of actions is performed in the
|
first forty clock ticks of every 100 clock ticks, while the
|
first forty clock ticks of every 100 clock ticks, while the
|
second set of actions is performed between the fortieth and
|
second set of actions is performed between the fortieth and
|
seventieth clock ticks. The last thirty clock ticks are not
|
seventieth clock ticks. The last thirty clock ticks are not
|
used by this task.
|
used by this task.
|
|
|
@page
|
@page
|
@example
|
@example
|
rtems_task Periodic_task(rtems_task_argument arg)
|
rtems_task Periodic_task(rtems_task_argument arg)
|
@{
|
@{
|
rtems_name name_1, name_2;
|
rtems_name name_1, name_2;
|
rtems_id period_1, period_2;
|
rtems_id period_1, period_2;
|
rtems_status_code status;
|
rtems_status_code status;
|
|
|
name_1 = rtems_build_name( 'P', 'E', 'R', '1' );
|
name_1 = rtems_build_name( 'P', 'E', 'R', '1' );
|
name_2 = rtems_build_name( 'P', 'E', 'R', '2' );
|
name_2 = rtems_build_name( 'P', 'E', 'R', '2' );
|
|
|
(void ) rtems_rate_monotonic_create( name_1, &period_1 );
|
(void ) rtems_rate_monotonic_create( name_1, &period_1 );
|
(void ) rtems_rate_monotonic_create( name_2, &period_2 );
|
(void ) rtems_rate_monotonic_create( name_2, &period_2 );
|
|
|
while ( 1 ) @{
|
while ( 1 ) @{
|
if ( rtems_rate_monotonic_period( period_1, 100 ) == TIMEOUT )
|
if ( rtems_rate_monotonic_period( period_1, 100 ) == TIMEOUT )
|
break;
|
break;
|
|
|
if ( rtems_rate_monotonic_period( period_2, 40 ) == TIMEOUT )
|
if ( rtems_rate_monotonic_period( period_2, 40 ) == TIMEOUT )
|
break;
|
break;
|
|
|
/*
|
/*
|
* Perform first set of actions between clock
|
* Perform first set of actions between clock
|
* ticks 0 and 39 of every 100 ticks.
|
* ticks 0 and 39 of every 100 ticks.
|
*/
|
*/
|
|
|
if ( rtems_rate_monotonic_period( period_2, 30 ) == TIMEOUT )
|
if ( rtems_rate_monotonic_period( period_2, 30 ) == TIMEOUT )
|
break;
|
break;
|
|
|
/*
|
/*
|
* Perform second set of actions between clock 40 and 69
|
* Perform second set of actions between clock 40 and 69
|
* of every 100 ticks. THEN ...
|
* of every 100 ticks. THEN ...
|
*
|
*
|
* Check to make sure we didn't miss the period_2 period.
|
* Check to make sure we didn't miss the period_2 period.
|
*/
|
*/
|
|
|
if ( rtems_rate_monotonic_period( period_2, STATUS ) == TIMEOUT )
|
if ( rtems_rate_monotonic_period( period_2, STATUS ) == TIMEOUT )
|
break;
|
break;
|
|
|
(void) rtems_rate_monotonic_cancel( period_2 );
|
(void) rtems_rate_monotonic_cancel( period_2 );
|
@}
|
@}
|
|
|
/* missed period so delete period and SELF */
|
/* missed period so delete period and SELF */
|
|
|
(void ) rtems_rate_monotonic_delete( period_1 );
|
(void ) rtems_rate_monotonic_delete( period_1 );
|
(void ) rtems_rate_monotonic_delete( period_2 );
|
(void ) rtems_rate_monotonic_delete( period_2 );
|
(void ) task_delete( SELF );
|
(void ) task_delete( SELF );
|
@}
|
@}
|
@end example
|
@end example
|
|
|
The above task creates two rate monotonic periods as
|
The above task creates two rate monotonic periods as
|
part of its initialization. The first time the loop is
|
part of its initialization. The first time the loop is
|
executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
executed, the @code{@value{DIRPREFIX}rate_monotonic_period}
|
directive will initiate the period_1 period for 100 ticks
|
directive will initiate the period_1 period for 100 ticks
|
and return immediately. Subsequent invocations of the
|
and return immediately. Subsequent invocations of the
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive
|
for period_1 will result in the task blocking for the remainder
|
for period_1 will result in the task blocking for the remainder
|
of the 100 tick period. The period_2 period is used to control
|
of the 100 tick period. The period_2 period is used to control
|
the execution time of the two sets of actions within each 100
|
the execution time of the two sets of actions within each 100
|
tick period established by period_1. The
|
tick period established by period_1. The
|
@code{@value{DIRPREFIX}rate_monotonic_cancel( period_2 )}
|
@code{@value{DIRPREFIX}rate_monotonic_cancel( period_2 )}
|
call is performed to ensure that the period_2 period
|
call is performed to ensure that the period_2 period
|
does not expire while the task is blocked on the period_1
|
does not expire while the task is blocked on the period_1
|
period. If this cancel operation were not performed, every time
|
period. If this cancel operation were not performed, every time
|
the @code{@value{DIRPREFIX}rate_monotonic_period( period_2, 40 )}
|
the @code{@value{DIRPREFIX}rate_monotonic_period( period_2, 40 )}
|
call is executed, except for the initial one, a directive status
|
call is executed, except for the initial one, a directive status
|
of @code{@value{RPREFIX}TIMEOUT} is returned. It is important to
|
of @code{@value{RPREFIX}TIMEOUT} is returned. It is important to
|
note that every time this call is made, the period_2 period will be
|
note that every time this call is made, the period_2 period will be
|
initiated immediately and the task will not block.
|
initiated immediately and the task will not block.
|
|
|
If, for any reason, the task misses any deadline, the
|
If, for any reason, the task misses any deadline, the
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive will
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive will
|
return the @code{@value{RPREFIX}TIMEOUT}
|
return the @code{@value{RPREFIX}TIMEOUT}
|
directive status. If the above task misses its deadline, it
|
directive status. If the above task misses its deadline, it
|
will delete the rate monotonic periods and itself.
|
will delete the rate monotonic periods and itself.
|
|
|
@section Directives
|
@section Directives
|
|
|
This section details the rate monotonic manager's
|
This section details the rate monotonic manager's
|
directives. A subsection is dedicated to each of this manager's
|
directives. A subsection is dedicated to each of this manager's
|
directives and describes the calling sequence, related
|
directives and describes the calling sequence, related
|
constants, usage, and status codes.
|
constants, usage, and status codes.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_CREATE - Create a rate monotonic period
|
@subsection RATE_MONOTONIC_CREATE - Create a rate monotonic period
|
|
|
@cindex create a period
|
@cindex create a period
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_create
|
@findex rtems_rate_monotonic_create
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_create(
|
rtems_status_code rtems_rate_monotonic_create(
|
rtems_name name,
|
rtems_name name,
|
rtems_id *id
|
rtems_id *id
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Create (
|
procedure Rate_Monotonic_Create (
|
Name : in RTEMS.Name;
|
Name : in RTEMS.Name;
|
ID : out RTEMS.ID;
|
ID : out RTEMS.ID;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - rate monotonic period created successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - rate monotonic period created successfully@*
|
@code{@value{RPREFIX}INVALID_NAME} - invalid task name@*
|
@code{@value{RPREFIX}INVALID_NAME} - invalid task name@*
|
@code{@value{RPREFIX}TOO_MANY} - too many periods created
|
@code{@value{RPREFIX}TOO_MANY} - too many periods created
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive creates a rate monotonic period. The
|
This directive creates a rate monotonic period. The
|
assigned rate monotonic id is returned in id. This id is used
|
assigned rate monotonic id is returned in id. This id is used
|
to access the period with other rate monotonic manager
|
to access the period with other rate monotonic manager
|
directives. For control and maintenance of the rate monotonic
|
directives. For control and maintenance of the rate monotonic
|
period, RTEMS allocates a PCB from the local PCB free pool and
|
period, RTEMS allocates a PCB from the local PCB free pool and
|
initializes it.
|
initializes it.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the calling task to be
|
This directive will not cause the calling task to be
|
preempted.
|
preempted.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_IDENT - Get ID of a period
|
@subsection RATE_MONOTONIC_IDENT - Get ID of a period
|
|
|
@cindex get ID of a period
|
@cindex get ID of a period
|
@cindex obtain ID of a period
|
@cindex obtain ID of a period
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_ident
|
@findex rtems_rate_monotonic_ident
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_ident(
|
rtems_status_code rtems_rate_monotonic_ident(
|
rtems_name name,
|
rtems_name name,
|
rtems_id *id
|
rtems_id *id
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Ident (
|
procedure Rate_Monotonic_Ident (
|
Name : in RTEMS.Name;
|
Name : in RTEMS.Name;
|
ID : out RTEMS.ID;
|
ID : out RTEMS.ID;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - period identified successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - period identified successfully@*
|
@code{@value{RPREFIX}INVALID_NAME} - period name not found
|
@code{@value{RPREFIX}INVALID_NAME} - period name not found
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive obtains the period id associated with
|
This directive obtains the period id associated with
|
the period name to be acquired. If the period name is not
|
the period name to be acquired. If the period name is not
|
unique, then the period id will match one of the periods with
|
unique, then the period id will match one of the periods with
|
that name. However, this period id is not guaranteed to
|
that name. However, this period id is not guaranteed to
|
correspond to the desired period. The period id is used to
|
correspond to the desired period. The period id is used to
|
access this period in other rate monotonic manager directives.
|
access this period in other rate monotonic manager directives.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the running task to be
|
This directive will not cause the running task to be
|
preempted.
|
preempted.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_CANCEL - Cancel a period
|
@subsection RATE_MONOTONIC_CANCEL - Cancel a period
|
|
|
@cindex cancel a period
|
@cindex cancel a period
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_cancel
|
@findex rtems_rate_monotonic_cancel
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_cancel(
|
rtems_status_code rtems_rate_monotonic_cancel(
|
rtems_id id
|
rtems_id id
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Cancel (
|
procedure Rate_Monotonic_Cancel (
|
ID : in RTEMS.ID;
|
ID : in RTEMS.ID;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - period canceled successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - period canceled successfully@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - rate monotonic period not created by calling task
|
@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - rate monotonic period not created by calling task
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive cancels the rate monotonic period id.
|
This directive cancels the rate monotonic period id.
|
This period will be reinitiated by the next invocation of
|
This period will be reinitiated by the next invocation of
|
@code{@value{DIRPREFIX}rate_monotonic_period} with id.
|
@code{@value{DIRPREFIX}rate_monotonic_period} with id.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the running task to be
|
This directive will not cause the running task to be
|
preempted.
|
preempted.
|
|
|
The rate monotonic period specified by id must have
|
The rate monotonic period specified by id must have
|
been created by the calling task.
|
been created by the calling task.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_DELETE - Delete a rate monotonic period
|
@subsection RATE_MONOTONIC_DELETE - Delete a rate monotonic period
|
|
|
@cindex delete a period
|
@cindex delete a period
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_delete
|
@findex rtems_rate_monotonic_delete
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_delete(
|
rtems_status_code rtems_rate_monotonic_delete(
|
rtems_id id
|
rtems_id id
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Delete (
|
procedure Rate_Monotonic_Delete (
|
ID : in RTEMS.ID;
|
ID : in RTEMS.ID;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - period deleted successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - period deleted successfully@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive deletes the rate monotonic period
|
This directive deletes the rate monotonic period
|
specified by id. If the period is running, it is automatically
|
specified by id. If the period is running, it is automatically
|
canceled. The PCB for the deleted period is reclaimed by RTEMS.
|
canceled. The PCB for the deleted period is reclaimed by RTEMS.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the running task to be
|
This directive will not cause the running task to be
|
preempted.
|
preempted.
|
|
|
A rate monotonic period can be deleted by a task
|
A rate monotonic period can be deleted by a task
|
other than the task which created the period.
|
other than the task which created the period.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_PERIOD - Conclude current/Start next period
|
@subsection RATE_MONOTONIC_PERIOD - Conclude current/Start next period
|
|
|
@cindex conclude current period
|
@cindex conclude current period
|
@cindex start current period
|
@cindex start current period
|
@cindex period initiation
|
@cindex period initiation
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_period
|
@findex rtems_rate_monotonic_period
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_period(
|
rtems_status_code rtems_rate_monotonic_period(
|
rtems_id id,
|
rtems_id id,
|
rtems_interval length
|
rtems_interval length
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Period (
|
procedure Rate_Monotonic_Period (
|
ID : in RTEMS.ID;
|
ID : in RTEMS.ID;
|
Length : in RTEMS.Interval;
|
Length : in RTEMS.Interval;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - period not created by calling task@*
|
@code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - period not created by calling task@*
|
@code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated (only
|
@code{@value{RPREFIX}NOT_DEFINED} - period has never been initiated (only
|
possible when period is set to PERIOD_STATUS)@*
|
possible when period is set to PERIOD_STATUS)@*
|
@code{@value{RPREFIX}TIMEOUT} - period has expired
|
@code{@value{RPREFIX}TIMEOUT} - period has expired
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive initiates the rate monotonic period id
|
This directive initiates the rate monotonic period id
|
with a length of period ticks. If id is running, then the
|
with a length of period ticks. If id is running, then the
|
calling task will block for the remainder of the period before
|
calling task will block for the remainder of the period before
|
reinitiating the period with the specified period. If id was
|
reinitiating the period with the specified period. If id was
|
not running (either expired or never initiated), the period is
|
not running (either expired or never initiated), the period is
|
immediately initiated and the directive returns immediately.
|
immediately initiated and the directive returns immediately.
|
|
|
If invoked with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the
|
If invoked with a period of @code{@value{RPREFIX}PERIOD_STATUS} ticks, the
|
current state of id will be returned. The directive status
|
current state of id will be returned. The directive status
|
indicates the current state of the period. This does not alter
|
indicates the current state of the period. This does not alter
|
the state or period of the period.
|
the state or period of the period.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the running task to be preempted.
|
This directive will not cause the running task to be preempted.
|
|
|
@c
|
@c
|
@c
|
@c
|
@c
|
@c
|
@page
|
@page
|
@subsection RATE_MONOTONIC_GET_STATUS - Obtain status information on period
|
@subsection RATE_MONOTONIC_GET_STATUS - Obtain status information on period
|
|
|
@cindex get status of period
|
@cindex get status of period
|
@cindex obtain status of period
|
@cindex obtain status of period
|
|
|
@subheading CALLING SEQUENCE:
|
@subheading CALLING SEQUENCE:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_get_status
|
@findex rtems_rate_monotonic_get_status
|
@example
|
@example
|
rtems_status_code rtems_rate_monotonic_get_status(
|
rtems_status_code rtems_rate_monotonic_get_status(
|
rtems_id id,
|
rtems_id id,
|
rtems_rate_monotonic_period_status *status
|
rtems_rate_monotonic_period_status *status
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
procedure Rate_Monotonic_Get_Status (
|
procedure Rate_Monotonic_Get_Status (
|
ID : in RTEMS.ID;
|
ID : in RTEMS.ID;
|
Status : out RTEMS.Rate_Monotonic_Period_Status;
|
Status : out RTEMS.Rate_Monotonic_Period_Status;
|
Result : out RTEMS.Status_Codes
|
Result : out RTEMS.Status_Codes
|
);
|
);
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@subheading DIRECTIVE STATUS CODES:
|
@subheading DIRECTIVE STATUS CODES:
|
@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
|
@code{@value{RPREFIX}SUCCESSFUL} - period initiated successfully@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}INVALID_ID} - invalid rate monotonic period id@*
|
@code{@value{RPREFIX}INVALID_ADDRESS} - invalid address of status@*
|
@code{@value{RPREFIX}INVALID_ADDRESS} - invalid address of status@*
|
|
|
@subheading DESCRIPTION:
|
@subheading DESCRIPTION:
|
|
|
This directive returns status information associated with
|
This directive returns status information associated with
|
the rate monotonic period id in the following data @value{STRUCTURE}:
|
the rate monotonic period id in the following data @value{STRUCTURE}:
|
|
|
@ifset is-C
|
@ifset is-C
|
@findex rtems_rate_monotonic_period_status
|
@findex rtems_rate_monotonic_period_status
|
@example
|
@example
|
typedef struct @{
|
typedef struct @{
|
rtems_rate_monotonic_period_states state;
|
rtems_rate_monotonic_period_states state;
|
rtems_unsigned32 ticks_since_last_period;
|
rtems_unsigned32 ticks_since_last_period;
|
rtems_unsigned32 ticks_executed_since_last_period;
|
rtems_unsigned32 ticks_executed_since_last_period;
|
@} rtems_rate_monotonic_period_status;
|
@} rtems_rate_monotonic_period_status;
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@ifset is-Ada
|
@ifset is-Ada
|
@example
|
@example
|
type Rate_Monotonic_Period_Status is
|
type Rate_Monotonic_Period_Status is
|
begin
|
begin
|
State : RTEMS.Rate_Monotonic_Period_States;
|
State : RTEMS.Rate_Monotonic_Period_States;
|
Ticks_Since_Last_Period : RTEMS.Unsigned32;
|
Ticks_Since_Last_Period : RTEMS.Unsigned32;
|
Ticks_Executed_Since_Last_Period : RTEMS.Unsigned32;
|
Ticks_Executed_Since_Last_Period : RTEMS.Unsigned32;
|
end record;
|
end record;
|
@end example
|
@end example
|
@end ifset
|
@end ifset
|
|
|
@c RATE_MONOTONIC_INACTIVE does not have RTEMS_ in front of it.
|
@c RATE_MONOTONIC_INACTIVE does not have RTEMS_ in front of it.
|
|
|
If the period's state is @code{RATE_MONOTONIC_INACTIVE}, both
|
If the period's state is @code{RATE_MONOTONIC_INACTIVE}, both
|
ticks_since_last_period and ticks_executed_since_last_period
|
ticks_since_last_period and ticks_executed_since_last_period
|
will be set to 0. Otherwise, ticks_since_last_period will
|
will be set to 0. Otherwise, ticks_since_last_period will
|
contain the number of clock ticks which have occurred since
|
contain the number of clock ticks which have occurred since
|
the last invocation of the
|
the last invocation of the
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
@code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
Also in this case, the ticks_executed_since_last_period will indicate
|
Also in this case, the ticks_executed_since_last_period will indicate
|
how much processor time the owning task has consumed since the invocation
|
how much processor time the owning task has consumed since the invocation
|
of the @code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
of the @code{@value{DIRPREFIX}rate_monotonic_period} directive.
|
|
|
@subheading NOTES:
|
@subheading NOTES:
|
|
|
This directive will not cause the running task to be preempted.
|
This directive will not cause the running task to be preempted.
|
|
|