1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Task Priorities</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-D.html">Previous</A> <A HREF="AA-D-2.html">Next</A></P>
<HR>
<H1> D.1 Task Priorities</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [This clause specifies the priority model for
real-time systems. In addition, the methods for specifying priorities
are defined.] </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented" Style="margin-bottom: 0.2em">The form of
a <FONT FACE="Arial, Helvetica">pragma</FONT> Priority is as follows:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6764"></A>Priority(<A NAME="I6765"></A><FONT FACE="Arial, Helvetica">expression</FONT>);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented" Style="margin-bottom: 0.2em">The form of
a <FONT FACE="Arial, Helvetica">pragma</FONT> Interrupt_Priority is as
follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6766"></A>Interrupt_Priority[(<A NAME="I6767"></A><FONT FACE="Arial, Helvetica">expression</FONT>)];
</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6768"></A><A NAME="I6769"></A>The expected
type for the <FONT FACE="Arial, Helvetica">expression</FONT> in a Priority
or Interrupt_Priority pragma is Integer. </DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> A Priority pragma is allowed only immediately
within a <FONT FACE="Arial, Helvetica">task_definition</FONT>, a <FONT FACE="Arial, Helvetica">protected_definition</FONT>,
or the <FONT FACE="Arial, Helvetica">declarative_part</FONT> of a <FONT FACE="Arial, Helvetica">subprogram_body</FONT>.
An Interrupt_Priority pragma is allowed only immediately within a <FONT FACE="Arial, Helvetica">task_definition</FONT>
or a <FONT FACE="Arial, Helvetica">protected_definition</FONT>. At most
one such pragma shall appear within a given construct.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> For a Priority pragma that appears in the <FONT FACE="Arial, Helvetica">declarative_part</FONT>
of a <FONT FACE="Arial, Helvetica">subprogram_body</FONT>, the <FONT FACE="Arial, Helvetica">expression</FONT>
shall be static, and its value shall be in the range of System.Priority.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This value is needed
before it gets elaborated, when the environment task starts executing.
</FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The following declarations
exist in package System: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT><B>subtype</B> Any_Priority <B>is</B> Integer <B>range</B> <I>implementation-defined</I>;<BR>
<B>subtype</B> Priority <B>is</B> Any_Priority<BR>
<B>range</B> Any_Priority'First .. <I>implementation-defined</I>;<BR>
<B>subtype</B> Interrupt_Priority <B>is</B> Any_Priority<BR>
<B>range</B> Priority'Last+1 .. Any_Priority'Last;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT>Default_Priority : <B>constant</B> Priority := (Priority'First + Priority'Last)/2;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
declarations of Any_Priority and Priority.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> The full range of priority values supported by
an implementation is specified by the subtype Any_Priority. The subrange
of priority values that are high enough to require the blocking of one
or more interrupts is specified by the subtype Interrupt_Priority. [The
subrange of priority values below System.Interrupt_Priority'First is
specified by the subtype System.Priority.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> The priority specified by a Priority or Interrupt_Priority
pragma is the value of the <FONT FACE="Arial, Helvetica">expression</FONT>
in the pragma, if any. If there is no <FONT FACE="Arial, Helvetica">expression</FONT>
in an Interrupt_Priority pragma, the priority value is Interrupt_Priority'Last.</DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> A Priority pragma has no effect if it occurs
in the <FONT FACE="Arial, Helvetica">declarative_part</FONT> of the <FONT FACE="Arial, Helvetica">subprogram_body</FONT>
of a subprogram other than the main subprogram.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6770"></A><A NAME="I6771"></A><A NAME="I6772"></A><A NAME="I6773"></A><A NAME="I6774"></A>A
<I>task priority</I> is an integer value that indicates a degree of urgency
and is the basis for resolving competing demands of tasks for resources.
Unless otherwise specified, whenever tasks compete for processors or
other implementation-defined resources, the resources are allocated to
the task with the highest priority value. The <I>base priority</I> of
a task is the priority with which it was created, or to which it was
later set by Dynamic_Priorities.Set_Priority (see <A HREF="AA-D-5.html">D.5</A>).
At all times, a task also has an <I>active priority</I>, which generally
reflects its base priority as well as any priority it inherits from other
sources. <I>Priority inheritance</I> is the process by which the priority
of a task or other entity (e.g. a protected object; see <A HREF="AA-D-3.html">D.3</A>)
is used in the evaluation of another task's active priority. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Implementation-defined
execution resources.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal"> The effect of specifying such a pragma in a <FONT FACE="Arial, Helvetica">protected_definition</FONT>
is discussed in <A HREF="AA-D-3.html">D.3</A>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6775"></A>The <FONT FACE="Arial, Helvetica">expression</FONT>
in a Priority or Interrupt_Priority pragma that appears in a <FONT FACE="Arial, Helvetica">task_definition</FONT>
is evaluated for each task object (see <A HREF="AA-9-1.html">9.1</A>).
For a Priority pragma, the value of the <FONT FACE="Arial, Helvetica">expression</FONT>
is converted to the subtype Priority; for an Interrupt_Priority pragma,
this value is converted to the subtype Any_Priority. The priority value
is then associated with the task object whose <FONT FACE="Arial, Helvetica">task_definition</FONT>
contains the pragma. <A NAME="I6776"></A><A NAME="I6777"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Normal"> Likewise, the priority value is associated with
the environment task if the pragma appears in the <FONT FACE="Arial, Helvetica">declarative_part</FONT>
of the main subprogram.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Normal"> The initial value of a task's base priority is
specified by default or by means of a Priority or Interrupt_Priority
pragma. [After a task is created, its base priority can be changed only
by a call to Dynamic_Priorities.Set_Priority (see <A HREF="AA-D-5.html">D.5</A>).]
The initial base priority of a task in the absence of a pragma is the
base priority of the task that creates it at the time of creation (see
<A HREF="AA-9-1.html">9.1</A>). If a pragma Priority does not apply to
the main subprogram, the initial base priority of the environment task
is System.Default_Priority. [The task's active priority is used when
the task competes for processors. Similarly, the task's active priority
is used to determine the task's position in any queue when Priority_Queuing
is specified (see <A HREF="AA-D-4.html">D.4</A>).]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> At any time, the
active priority of a task is the maximum of all the priorities the task
is inheriting at that instant. For a task that is not held (see <A HREF="AA-D-11.html">D.11</A>),
its base priority is always a source of priority inheritance. Other sources
of priority inheritance are specified under the following conditions:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>Other parts
of the annex, e.g. <A HREF="AA-D-11.html">D.11</A>, define other sources
of priority inheritance. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0072">8652/0072</A></I>}
During activation, a task being activated inherits the active priority
<U>that</U><S>of the</S> its activator (see <A HREF="AA-9-2.html">9.2</A>)<U>
had at the time the activation was initiated</U>.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>22/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0072">8652/0072</A></I>}
During rendezvous, the task accepting the entry call inherits the <S>active
</S>priority of the <U>entry call</U><S>caller</S> (see <A HREF="AA-9-5-3.html">9.5.3</A><U>
and <A HREF="AA-D-4.html">D.4</A></U>).</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>During a protected action on a protected object, a task
inherits the ceiling priority of the protected object (see <A HREF="AA-9-5.html">9.5</A>
and <A HREF="AA-D-3.html">D.3</A>).</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal"> In all of these cases, the priority ceases to
be inherited as soon as the condition calling for the inheritance no
longer exists.</DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal"> The range of System.Interrupt_Priority shall
include at least one value.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Normal"> The range of System.Priority shall include at
least 30 values.</DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>4 The priority expression
can include references to discriminants of the enclosing type.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>5 It is a consequence of
the active priority rules that at the point when a task stops inheriting
a priority from another source, its active priority is re-evaluated.
This is in addition to other instances described in this Annex for such
re-evaluation.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>6 An implementation may provide
a non-standard mode in which tasks inherit priorities under conditions
other than those specified above. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The use of
a Priority or Interrupt_Priority pragma does not require the package
System to be named in a <FONT FACE="Arial, Helvetica">with_clause</FONT>
for the enclosing <FONT FACE="Arial, Helvetica">compilation_unit</FONT>.
</FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>29.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I6778"></A>The priority
of a task is per-object and not per-type.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Priorities need not be static
anymore (except for the main subprogram).</FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>29.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The description of the Priority
pragma has been moved to this annex.</FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-D.html">Previous</A> <A HREF="AA-D-2.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|