| 1 |
@Comment{ $Source: e:\\cvsroot/ARM/Source/rt.mss,v $ } |
| 2 |
@comment{ $Revision: 1.75 $ $Date: 2006/10/19 06:40:31 $ $Author: Randy $ } |
| 3 |
@Part(realtime, Root="ada.mss") |
| 4 |
@Comment{$Date: 2006/10/19 06:40:31 $} |
| 5 |
|
| 6 |
@LabeledNormativeAnnex{Real-Time Systems} |
| 7 |
|
| 8 |
@begin{Intro} |
| 9 |
@Defn{real-time systems} |
| 10 |
@Defn{embedded systems} |
| 11 |
This Annex specifies additional characteristics of Ada implementations |
| 12 |
intended for real-time systems software. To conform to this Annex, an |
| 13 |
implementation shall also conform to the Systems Programming Annex. |
| 14 |
@end{Intro} |
| 15 |
|
| 16 |
@begin{Metrics} |
| 17 |
|
| 18 |
The metrics are documentation requirements; an implementation shall |
| 19 |
document the values of the language-defined metrics for at least one |
| 20 |
configuration @Redundant[of hardware or an underlying system] supported by |
| 21 |
the implementation, and shall document the details of that configuration. |
| 22 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 23 |
Text=[Values of all @MetricsTitle.]}]}@ChgNote{We're going to document the |
| 24 |
individual metrics sections.} |
| 25 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 26 |
Text=[The details of the configuration used to generate the values of all |
| 27 |
metrics.]}]} |
| 28 |
@begin{Reason} |
| 29 |
The actual values of the metrics are likely to depend on hardware |
| 30 |
configuration details that are variable and generally outside the control |
| 31 |
of a compiler vendor. |
| 32 |
@end{Reason} |
| 33 |
|
| 34 |
The metrics do not necessarily yield a simple number. |
| 35 |
@Redundant[For some, a range is more suitable, for others a formula |
| 36 |
dependent on some parameter is appropriate, and for |
| 37 |
others, |
| 38 |
it may be more suitable to break the metric into several cases.] |
| 39 |
Unless specified otherwise, the metrics in this annex are expressed in |
| 40 |
processor clock cycles. |
| 41 |
For metrics that require documentation of an upper bound, |
| 42 |
if there is no upper bound, |
| 43 |
the implementation shall report that the metric is unbounded. |
| 44 |
@begin{Discussion} |
| 45 |
There are several good reasons to specify metrics in seconds; there are however |
| 46 |
equally good reasons to specify them in processor clock cycles. In |
| 47 |
defining the metrics, we have tried to strike a balance on a case-by-case |
| 48 |
basis. |
| 49 |
|
| 50 |
It has been suggested that all metrics should be given names, |
| 51 |
so that @lquotes@;data-sheets@rquotes@; could be formulated and published |
| 52 |
by vendors. |
| 53 |
However the paragraph number can serve that purpose. |
| 54 |
@end{Discussion} |
| 55 |
|
| 56 |
@end{Metrics} |
| 57 |
|
| 58 |
@begin{Notes} |
| 59 |
|
| 60 |
The specification of the metrics makes a distinction between upper bounds |
| 61 |
and simple execution times. Where something is just specified as @lquotes@;the |
| 62 |
execution time of@rquotes@; a piece of code, this leaves one |
| 63 |
the freedom |
| 64 |
to choose a nonpathological case. This kind of metric is of the form |
| 65 |
@lquotes@;there exists a program such that the value of the metric is V@rquotes@;. |
| 66 |
Conversely, the meaning of upper bounds is @lquotes@;there is no program such |
| 67 |
that the value of the metric is greater than V@rquotes@;. |
| 68 |
This kind of metric can only be partially tested, by finding the value |
| 69 |
of V for one or more test programs. |
| 70 |
|
| 71 |
The metrics do not cover the whole language; they are limited |
| 72 |
to features that are specified in @RefSec{Systems Programming} |
| 73 |
and in this Annex. The metrics are intended |
| 74 |
to provide guidance to potential users as to whether a particular |
| 75 |
implementation of such a feature is going to be adequate for a |
| 76 |
particular real-time application. As such, the metrics are aimed |
| 77 |
at known implementation choices that can result in significant |
| 78 |
performance differences. |
| 79 |
|
| 80 |
The purpose of the metrics is not necessarily to provide fine-grained |
| 81 |
quantitative results or to serve as a comparison between different |
| 82 |
implementations on the same or different platforms. Instead, their |
| 83 |
goal is rather qualitative; to define a standard set of approximate values |
| 84 |
that can be measured and used to estimate the general suitability of an |
| 85 |
implementation, or to evaluate the comparative utility of certain features |
| 86 |
of an implementation for a particular real-time application. |
| 87 |
|
| 88 |
@end{Notes} |
| 89 |
|
| 90 |
@begin{Extend83} |
| 91 |
@Defn{extensions to Ada 83} |
| 92 |
This Annex is new to Ada 95. |
| 93 |
@end{Extend83} |
| 94 |
|
| 95 |
|
| 96 |
@LabeledClause{Task Priorities} |
| 97 |
@begin{Intro} |
| 98 |
@Redundant[This clause specifies the priority model for real-time systems. |
| 99 |
In addition, the methods for specifying priorities are defined.] |
| 100 |
@end{Intro} |
| 101 |
|
| 102 |
@begin{Syntax} |
| 103 |
@begin{SyntaxText} |
| 104 |
@leading@keepnext@;The form of a @nt{pragma} Priority is as follows: |
| 105 |
@end{SyntaxText} |
| 106 |
|
| 107 |
@PragmaSyn`@key{pragma} @prag(Priority)(@Syn2{expression});' |
| 108 |
|
| 109 |
@begin{SyntaxText} |
| 110 |
@leading@keepnext@;The form of a @nt{pragma} Interrupt_Priority is as follows: |
| 111 |
@end{SyntaxText} |
| 112 |
|
| 113 |
@PragmaSyn`@key{pragma} @prag(Interrupt_Priority)[(@Syn2{expression})];' |
| 114 |
@end{Syntax} |
| 115 |
|
| 116 |
@begin{Resolution} |
| 117 |
|
| 118 |
@PDefn2{Term=[expected type], |
| 119 |
Sec=(Priority pragma argument)} |
| 120 |
@PDefn2{Term=[expected type], |
| 121 |
Sec=(Interrupt_Priority pragma argument)} |
| 122 |
The expected type for the @nt{expression} in a Priority |
| 123 |
or Interrupt_Priority pragma is Integer. |
| 124 |
@end{Resolution} |
| 125 |
|
| 126 |
@begin{Legality} |
| 127 |
|
| 128 |
A Priority pragma is allowed only immediately within a @nt{task_definition}, |
| 129 |
a @nt{protected_definition}, or the @nt{declarative_part} of a |
| 130 |
@nt{subprogram_body}. An Interrupt_Priority pragma is allowed only |
| 131 |
immediately within a @nt{task_definition} or a @nt{protected_definition}. |
| 132 |
At most one such pragma shall appear within a given construct. |
| 133 |
|
| 134 |
For a Priority pragma that appears in the @nt{declarative_part} of a |
| 135 |
@nt{subprogram_body}, the @nt{expression} shall be static, and its value shall |
| 136 |
be in the range of System.Priority. |
| 137 |
@begin{Reason} |
| 138 |
This value is needed before it gets elaborated, when the environment task |
| 139 |
starts executing. |
| 140 |
@end{Reason} |
| 141 |
|
| 142 |
@end{Legality} |
| 143 |
|
| 144 |
@begin{StaticSem} |
| 145 |
|
| 146 |
@leading@keepnext@;The following declarations exist in package System: |
| 147 |
@begin{example} |
| 148 |
@key{subtype} Any_Priority @key{is} Integer @key{range} @RI{implementation-defined}; |
| 149 |
@key{subtype} Priority @key{is} Any_Priority |
| 150 |
@key{range} Any_Priority'First .. @RI{implementation-defined}; |
| 151 |
@key{subtype} Interrupt_Priority @key{is} Any_Priority |
| 152 |
@key{range} Priority'Last+1 .. Any_Priority'Last; |
| 153 |
|
| 154 |
Default_Priority : @key{constant} Priority := (Priority'First + Priority'Last)/2; |
| 155 |
@end{example} |
| 156 |
@ImplDef{The declarations of Any_Priority and Priority.} |
| 157 |
|
| 158 |
The full range of priority values supported by an implementation is specified |
| 159 |
by the subtype Any_Priority. The subrange of priority values that are high |
| 160 |
enough to require the blocking of one or more interrupts is specified by the |
| 161 |
subtype Interrupt_@!Priority. @Redundant[The subrange of priority values below |
| 162 |
System.@!Interrupt_@!Priority'First is specified by the subtype System.@!Priority.] |
| 163 |
|
| 164 |
The priority specified by a Priority or Interrupt_Priority pragma is the |
| 165 |
value of the @nt{expression} in the pragma, if any. If there is no |
| 166 |
@nt{expression} in an Interrupt_Priority pragma, the priority value is |
| 167 |
Interrupt_Priority'Last. |
| 168 |
|
| 169 |
@end{StaticSem} |
| 170 |
|
| 171 |
@begin{RunTime} |
| 172 |
|
| 173 |
A Priority pragma has no effect |
| 174 |
if it occurs in the @nt{declarative_part} of the @nt{subprogram_body} of a |
| 175 |
subprogram other than the main subprogram. |
| 176 |
|
| 177 |
@Defn{task priority} |
| 178 |
@Defn{priority} |
| 179 |
@Defn{priority inheritance} |
| 180 |
@Defn{base priority} |
| 181 |
@Defn{active priority} |
| 182 |
A @i{task priority} is an integer value that indicates a degree of urgency |
| 183 |
and is the basis for resolving competing demands of tasks for |
| 184 |
resources. Unless otherwise specified, whenever tasks compete |
| 185 |
for processors or other implementation-defined resources, the |
| 186 |
resources are allocated to the task with the highest priority |
| 187 |
value. |
| 188 |
The @i{base priority} of a task is the priority with which it was |
| 189 |
created, or to which it was later set by Dynamic_Priorities.Set_Priority |
| 190 |
(see @RefSecNum{Dynamic Priorities}). At all times, a task also has |
| 191 |
an @i{active priority}, which generally reflects its base priority |
| 192 |
as well as any priority it inherits from other sources. |
| 193 |
@i{Priority inheritance} is the process by which the priority of a |
| 194 |
task or other entity (e.g. a protected object; |
| 195 |
see @RefSecNum{Priority Ceiling Locking}) is used in the evaluation of another |
| 196 |
task's active priority. |
| 197 |
@ImplDef{Implementation-defined execution resources.} |
| 198 |
|
| 199 |
The effect of specifying such a pragma in a @nt{protected_definition} |
| 200 |
is discussed in @RefSecNum{Priority Ceiling Locking}. |
| 201 |
|
| 202 |
@Defn2{Term=[creation], Sec=(of a task object)} |
| 203 |
The @nt{expression} in a Priority or Interrupt_Priority pragma that |
| 204 |
appears in a @nt{task_definition} is evaluated for each task object |
| 205 |
(see @RefSecNum{Task Units and Task Objects}). |
| 206 |
For a Priority pragma, the |
| 207 |
value of the @nt{expression} is converted to the subtype Priority; for an |
| 208 |
Interrupt_Priority pragma, this value is converted to the subtype Any_Priority. |
| 209 |
The priority value is then associated with the task object whose |
| 210 |
@nt{task_definition} contains the pragma. |
| 211 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)} |
| 212 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)} |
| 213 |
|
| 214 |
Likewise, the priority value is associated with the environment task if the |
| 215 |
pragma appears in the @nt{declarative_part} of the main subprogram. |
| 216 |
|
| 217 |
The initial value of a task's base priority is specified by default or |
| 218 |
by means of a Priority or Interrupt_Priority pragma. |
| 219 |
@Redundant[After a task is created, |
| 220 |
its base priority can be changed only by a call to |
| 221 |
Dynamic_Priorities.Set_Priority (see @RefSecNum{Dynamic Priorities}).] |
| 222 |
The initial base priority of a task in the absence of a pragma is the |
| 223 |
base priority of the task that creates it at the time of creation |
| 224 |
(see @RefSecNum{Task Units and Task Objects}). |
| 225 |
If a pragma Priority does not apply to the main subprogram, |
| 226 |
the initial base priority of the environment task is |
| 227 |
System.Default_Priority. |
| 228 |
@Redundant[The task's active priority is used when the task competes for |
| 229 |
processors. |
| 230 |
Similarly, the task's active priority is used |
| 231 |
to determine the task's position in any queue when Priority_Queuing is |
| 232 |
specified (see @RefSecNum{Entry Queuing Policies}).] |
| 233 |
|
| 234 |
@Leading@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]} |
| 235 |
At any time, the active priority of a task is the maximum of all the |
| 236 |
priorities the task is inheriting at that instant. For a task that is not |
| 237 |
held (see @RefSecNum{Asynchronous Task Control}), its base priority is |
| 238 |
@Chg{Version=[2],New=[],Old=[always ]}a source of priority inheritance |
| 239 |
@Chg{Version=[2],New=[unless otherwise |
| 240 |
specified for a particular task dispatching policy],Old=[]}. |
| 241 |
Other sources of priority inheritance are specified under the following |
| 242 |
conditions: |
| 243 |
@begin{Discussion} |
| 244 |
Other parts of the annex, e.g. |
| 245 |
@RefSecNum{Asynchronous Task Control}, define |
| 246 |
other sources of priority inheritance. |
| 247 |
@end{Discussion} |
| 248 |
@begin{itemize} |
| 249 |
|
| 250 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0072],ARef=[AI95-00092-01]} |
| 251 |
During activation, a task being activated inherits the active priority |
| 252 |
@Chg{New=[that],Old=[of the]} its activator (see |
| 253 |
@RefSecNum{Task Execution - Task Activation})@Chg{New=[ had at the time |
| 254 |
the activation was initiated],Old=[]}. |
| 255 |
|
| 256 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0072],ARef=[AI95-00092-01]} |
| 257 |
During rendezvous, the task accepting the entry call inherits the |
| 258 |
@Chg{New=[],Old=[active ]}priority of the @Chg{New=[entry call],Old=[caller]} |
| 259 |
(see @RefSecNum{Entry Calls}@Chg{New=[ and @RefSecNum{Entry Queuing Policies}],Old=[]}). |
| 260 |
|
| 261 |
During a protected action on a protected object, a task inherits the ceiling |
| 262 |
priority of the protected object (see @RefSecNum{Intertask Communication} and |
| 263 |
@RefSecNum{Priority Ceiling Locking}). |
| 264 |
|
| 265 |
@end{itemize} |
| 266 |
|
| 267 |
In all of these cases, the priority ceases to be |
| 268 |
inherited as soon as the condition calling for the inheritance no longer |
| 269 |
exists. |
| 270 |
|
| 271 |
@end{RunTime} |
| 272 |
|
| 273 |
@begin{ImplReq} |
| 274 |
|
| 275 |
The range of System.Interrupt_Priority shall include at least one value. |
| 276 |
|
| 277 |
The range of System.Priority shall include at least 30 values. |
| 278 |
|
| 279 |
@end{ImplReq} |
| 280 |
|
| 281 |
@begin{Notes} |
| 282 |
|
| 283 |
The priority expression can include references to |
| 284 |
discriminants of the enclosing type. |
| 285 |
|
| 286 |
It is a consequence of the active priority rules that at the point when |
| 287 |
a task stops inheriting a priority from another source, its active priority |
| 288 |
is re-evaluated. This is in addition to other instances described in this |
| 289 |
Annex for such re-evaluation. |
| 290 |
|
| 291 |
An implementation may provide a non-standard mode in which tasks |
| 292 |
inherit priorities under conditions other than those specified |
| 293 |
above. |
| 294 |
@begin{Ramification} |
| 295 |
The use of a Priority or Interrupt_Priority pragma does not |
| 296 |
require the package System to be named in a @nt{with_clause} for the |
| 297 |
enclosing @nt{compilation_unit}. |
| 298 |
@end{Ramification} |
| 299 |
|
| 300 |
@end{Notes} |
| 301 |
|
| 302 |
@begin{Extend83} |
| 303 |
@Defn{extensions to Ada 83} |
| 304 |
The priority of a task is per-object and not per-type. |
| 305 |
|
| 306 |
Priorities need not be static anymore (except for the main subprogram). |
| 307 |
|
| 308 |
@end{Extend83} |
| 309 |
|
| 310 |
@begin{DiffWord83} |
| 311 |
|
| 312 |
The description of the Priority pragma has been moved to this annex. |
| 313 |
|
| 314 |
@end{DiffWord83} |
| 315 |
|
| 316 |
@begin{DiffWord95} |
| 317 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0072],ARef=[AI95-00092-01]} |
| 318 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that dynamic |
| 319 |
priority changes are not transitive - that is, they don't apply to tasks |
| 320 |
that are being activated by or in rendezvous with the task that had its |
| 321 |
priority changed.]} |
| 322 |
|
| 323 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 324 |
@ChgAdded{Version=[2],Text=[Generalized the definition of priority |
| 325 |
inheritance to take into account the differences between the existing and |
| 326 |
new dispatching policies.]} |
| 327 |
@end{DiffWord95} |
| 328 |
|
| 329 |
|
| 330 |
@LabeledClause{Priority Scheduling} |
| 331 |
|
| 332 |
@begin{Intro} |
| 333 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 334 |
@Redundant[This clause describes the rules that determine which task is |
| 335 |
selected for execution when more than one task is ready |
| 336 |
(see @Chg{Version=[2],New=[@RefSecNum{Tasks and Synchronization}], |
| 337 |
Old=[@RefSecNum{Task Execution - Task Activation}]}).@Chg{Version=[2], |
| 338 |
New=[],Old=[ The rules have two parts: the task dispatching model |
| 339 |
(see @RefSecNum{The Task Dispatching Model}), |
| 340 |
and a specific task dispatching policy |
| 341 |
(see @RefSecNum{Task Dispatching Pragmas}).]}] |
| 342 |
@end{Intro} |
| 343 |
|
| 344 |
@begin{DiffWord95} |
| 345 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 346 |
@ChgAdded{Version=[2],Text=[This introduction is simplified in order to |
| 347 |
reflect the rearrangement and expansion of this clause.]} |
| 348 |
@end{DiffWord95} |
| 349 |
|
| 350 |
|
| 351 |
@LabeledSubClause{The Task Dispatching Model} |
| 352 |
|
| 353 |
@begin{Intro} |
| 354 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 355 |
@Redundant[The task dispatching model specifies @Chg{Version=[2], |
| 356 |
New=[task],Old=[preemptive]} scheduling, based on conceptual |
| 357 |
priority-ordered ready queues.] |
| 358 |
@end{Intro} |
| 359 |
|
| 360 |
@begin{StaticSem} |
| 361 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 362 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 363 |
language-defined library package exists:]} |
| 364 |
@begin{Example} |
| 365 |
@ChgRef{Version=[2],Kind=[Added]} |
| 366 |
@ChgAdded{Version=[2],Text=[@key<package> Ada.Dispatching @key<is>@ChildUnit{Parent=[Ada],Child=[Dispatching]} |
| 367 |
@key<pragma> Pure(Dispatching); |
| 368 |
@AdaExcDefn{Dispatching_Policy_Error} : @key<exception>; |
| 369 |
@key<end> Ada.Dispatching;]} |
| 370 |
@end{Example} |
| 371 |
|
| 372 |
@ChgRef{Version=[2],Kind=[Added]} |
| 373 |
@ChgAdded{Version=[2],Text=[Dispatching serves as the parent of other |
| 374 |
language-defined library units concerned with task dispatching.]} |
| 375 |
|
| 376 |
@end{StaticSem} |
| 377 |
|
| 378 |
@begin{RunTime} |
| 379 |
|
| 380 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 381 |
A task @Chg{Version=[2],New=[can become],Old=[runs (that is, it becomes]} a |
| 382 |
@i{running task}@Chg{Version=[2],New=[],Old=[)]} only @Chg{Version=[2], |
| 383 |
New=[if],Old=[when]} it is ready (see @Chg{Version=[2],New=[@RefSecNum{Tasks and Synchronization}], |
| 384 |
Old=[@RefSecNum{Task Execution - Task Activation}]}) and |
| 385 |
the execution resources required by that task are available. |
| 386 |
Processors are allocated to tasks based on each task's active priority. |
| 387 |
|
| 388 |
It is implementation defined whether, on a multiprocessor, a task that |
| 389 |
is waiting for access to a protected object keeps its processor busy. |
| 390 |
@ImplDef{Whether, on a multiprocessor, a task that |
| 391 |
is waiting for access to a protected object keeps its processor busy.} |
| 392 |
|
| 393 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 394 |
@Defn{task dispatching} |
| 395 |
@Defn{dispatching, task} |
| 396 |
@RootDefn{task dispatching point} |
| 397 |
@RootDefn{dispatching point} |
| 398 |
@i{Task dispatching} is the process by which one ready task is selected |
| 399 |
for execution on a processor. This selection is done at certain points |
| 400 |
during the execution of a task called @i{task dispatching points}. |
| 401 |
A task reaches a task dispatching point whenever it becomes blocked, |
| 402 |
and @Chg{Version=[2],New=[when it terminates],Old=[whenever it becomes ready. |
| 403 |
In addition, the completion of an @nt{accept_statement} |
| 404 |
(see @RefSecNum{Entries and Accept Statements}), and task termination are |
| 405 |
task dispatching points for the executing task]}. |
| 406 |
@Redundant[Other task dispatching points are defined |
| 407 |
throughout this Annex@Chg{Version=[2],New=[ for specific policies],Old=[]}.] |
| 408 |
@begin{Ramification} |
| 409 |
On multiprocessor systems, more than one task can be chosen, at the |
| 410 |
same time, for execution on more than one processor, as explained below. |
| 411 |
@end{Ramification} |
| 412 |
|
| 413 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 414 |
@Defn{ready queue} |
| 415 |
@Defn{head (of a queue)} |
| 416 |
@Defn{tail (of a queue)} |
| 417 |
@Defn{ready task} |
| 418 |
@PDefn{task dispatching policy} |
| 419 |
@PDefn{dispatching policy for tasks} |
| 420 |
@i{Task dispatching policies} are specified in terms of conceptual |
| 421 |
@i{ready queues}@Chg{Version=[2],New=[ and],Old=[,]} task states@Chg{Version=[2], |
| 422 |
New=[],Old=[, and task preemption]}. |
| 423 |
A ready queue is an ordered list of ready tasks. |
| 424 |
The first position in a queue is called the |
| 425 |
@i{head of the queue}, and the last position is called the |
| 426 |
@i{tail of the queue}. |
| 427 |
A task is @i{ready} if it is in a ready queue, |
| 428 |
or if it is running. |
| 429 |
Each processor has one ready queue for each priority value. At any instant, |
| 430 |
each ready queue of a processor contains exactly the set of tasks of that |
| 431 |
priority that are ready for execution on that |
| 432 |
processor, but are not running on any processor; that is, those tasks |
| 433 |
that are ready, are not running on any processor, and can be |
| 434 |
executed using that processor and other available resources. |
| 435 |
A task can be on the ready queues of more than one processor. |
| 436 |
@begin{Discussion} |
| 437 |
The core language defines a ready task as one that is not |
| 438 |
blocked. Here we refine this definition and |
| 439 |
talk about ready queues. |
| 440 |
@end{Discussion} |
| 441 |
|
| 442 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 443 |
@Defn{running task} |
| 444 |
Each processor also has one @i{running task}, |
| 445 |
which is the task currently being executed by that processor. |
| 446 |
Whenever a task running on a processor reaches a task dispatching |
| 447 |
point@Chg{Version=[2],New=[ it goes back to one or more ready queues; a], |
| 448 |
Old=[, one]} task @Chg{Version=[2],New=[(possibly the same task) ],Old=[]}is |
| 449 |
@Chg{Version=[2],New=[then ],Old=[]}selected to run on that processor. |
| 450 |
The task selected is the one at the head of the highest priority |
| 451 |
nonempty ready queue; |
| 452 |
this task is then removed from all ready queues to which it |
| 453 |
belongs. |
| 454 |
@begin{Discussion} |
| 455 |
There is always at least one task to run, |
| 456 |
if we count the idle task. |
| 457 |
@end{Discussion} |
| 458 |
|
| 459 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00321-01]} |
| 460 |
@ChgDeleted{Version=[2],Text=[@Defn{preemptible resource} |
| 461 |
A preemptible resource is a resource that while allocated |
| 462 |
to one task can be allocated (temporarily) to another |
| 463 |
instead. |
| 464 |
Processors are preemptible resources. Access to a protected object |
| 465 |
(see @RefSecNum{Protected Subprograms and Protected Actions}) |
| 466 |
is a nonpreemptible resource. |
| 467 |
@Defn{preempted task} |
| 468 |
When a higher-priority task is dispatched to the processor, and the previously |
| 469 |
running task is placed on the appropriate ready queue, the latter task |
| 470 |
is said to be @i{preempted}.]} |
| 471 |
@begin{Reason} |
| 472 |
@ChgRef{Version=[2],Kind=[Deleted]} |
| 473 |
@ChgDeleted{Version=[2],Text=[A processor that is executing a task is available |
| 474 |
to execute tasks of higher priority, within the set of tasks that that |
| 475 |
processor is able to execute. Write access to a protected object, on the other |
| 476 |
hand, cannot be granted to a new task before the old task has released it.]} |
| 477 |
@end{Reason} |
| 478 |
|
| 479 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00321-01]} |
| 480 |
@ChgDeleted{Version=[2],Text=[@PDefn{task dispatching point} |
| 481 |
@PDefn{dispatching point} |
| 482 |
A new running task is also selected whenever there is a nonempty ready queue |
| 483 |
with a higher priority than the priority of the running |
| 484 |
task, or when the task dispatching policy requires a |
| 485 |
running task to go back to a ready queue. |
| 486 |
@Redundant[These are also task dispatching points.]]} |
| 487 |
@begin{Ramification} |
| 488 |
@ChgRef{Version=[2],Kind=[Deleted]} |
| 489 |
@ChgDeleted{Version=[2],Text=[Thus, when a task becomes ready, this is a task |
| 490 |
dispatching point for all running tasks of lower priority.]} |
| 491 |
@end{Ramification} |
| 492 |
|
| 493 |
@end{RunTime} |
| 494 |
|
| 495 |
@begin{ImplPerm} |
| 496 |
|
| 497 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 498 |
An implementation is allowed to define additional resources as execution |
| 499 |
resources, and to define the corresponding allocation policies for them. |
| 500 |
Such resources may have an implementation@Chg{Version=[2],New=[-],Old=[ ]}defined |
| 501 |
effect on task dispatching@Chg{Version=[2],New=[], |
| 502 |
Old=[ (see @RefSecNum{Task Dispatching Pragmas})]}. |
| 503 |
@ChgImplDef{Version=[2],Kind=[Revised], |
| 504 |
Text=[The @Chg{Version=[2],New=[effect],Old=[affect]} of |
| 505 |
implementation@Chg{Version=[2],New=[-],Old=[ ]}defined |
| 506 |
execution resources on task dispatching.]} |
| 507 |
|
| 508 |
An implementation may place implementation-defined restrictions on |
| 509 |
tasks whose active priority is in the Interrupt_Priority range. |
| 510 |
@begin{Ramification} |
| 511 |
For example, on some operating systems, |
| 512 |
it might be necessary to disallow them altogether. |
| 513 |
This permission applies to tasks whose priority is set to interrupt |
| 514 |
level for any reason: via a pragma, |
| 515 |
via a call to Dynamic_Priorities.Set_Priority, |
| 516 |
or via priority inheritance. |
| 517 |
@end{Ramification} |
| 518 |
|
| 519 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00321-01]} |
| 520 |
@ChgNote{This was moved up from the previous section.} |
| 521 |
@ChgAdded{Version=[2],Text=[@Redundant[For optimization purposes,] |
| 522 |
an implementation may alter the points at which task dispatching occurs, in an |
| 523 |
implementation-defined manner. However, a @nt{delay_statement} always |
| 524 |
corresponds to at least one task dispatching point.]} |
| 525 |
|
| 526 |
@end{ImplPerm} |
| 527 |
|
| 528 |
@begin{Notes} |
| 529 |
|
| 530 |
Section 9 specifies under which circumstances a task |
| 531 |
becomes ready. |
| 532 |
The ready state is affected by the rules for |
| 533 |
task activation and termination, delay statements, and entry calls. |
| 534 |
@PDefn{blocked} |
| 535 |
When a task is not ready, it is said to be blocked. |
| 536 |
|
| 537 |
An example of a possible implementation-defined execution |
| 538 |
resource is a page of physical memory, which needs to be loaded |
| 539 |
with a particular page of virtual memory before a task can |
| 540 |
continue execution. |
| 541 |
|
| 542 |
The ready queues are purely conceptual; there is no requirement that such |
| 543 |
lists physically exist in an implementation. |
| 544 |
|
| 545 |
While a task is running, it is not on any ready queue. Any time |
| 546 |
the task that is running on a processor is added to a ready queue, |
| 547 |
a new running task is selected for that processor. |
| 548 |
|
| 549 |
In a multiprocessor system, a task can be on the ready queues of more than |
| 550 |
one processor. At the extreme, if several processors share the same set of |
| 551 |
ready tasks, the contents of their ready queues is identical, and so |
| 552 |
they can be viewed as sharing one ready queue, and can be implemented that |
| 553 |
way. |
| 554 |
@Redundant[Thus, the dispatching model covers |
| 555 |
multiprocessors where dispatching is implemented using a single |
| 556 |
ready queue, as well as those with separate dispatching domains.] |
| 557 |
|
| 558 |
The priority of a task is determined by rules specified in this subclause, and |
| 559 |
under @RefSec{Task Priorities}, @RefSec{Priority Ceiling Locking}, and |
| 560 |
@RefSec{Dynamic Priorities}. |
| 561 |
|
| 562 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 563 |
@ChgNote{This note is moved up from the next subclause.} |
| 564 |
@ChgAdded{Version=[2],Text=[The setting of a task's base priority as a result |
| 565 |
of a call to Set_Priority does not always take effect immediately when |
| 566 |
Set_Priority is called. The effect of setting the task's base priority is |
| 567 |
deferred while the affected task performs a protected action.]} |
| 568 |
|
| 569 |
@end{Notes} |
| 570 |
|
| 571 |
@begin{DiffWord95} |
| 572 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 573 |
@ChgAdded{Version=[2],Text=[This description is simplified to describe only |
| 574 |
the parts of the dispatching model common to all policies. In particular, |
| 575 |
rules about preemption are moved elsewhere. This makes |
| 576 |
it easier to add other policies (which may not involve preemption).]} |
| 577 |
@end{DiffWord95} |
| 578 |
|
| 579 |
|
| 580 |
@LabeledRevisedSubClause{Version=[2], |
| 581 |
New=[Task Dispatching Pragmas], |
| 582 |
Old=[The Standard Task Dispatching Policy]} |
| 583 |
|
| 584 |
@begin{Intro} |
| 585 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 586 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause allows a single task |
| 587 |
dispatching policy to be defined for all priorities, or the range of priorities |
| 588 |
to be split into subranges that are assigned individual dispatching |
| 589 |
policies.]]} |
| 590 |
@end{Intro} |
| 591 |
|
| 592 |
@begin{Syntax} |
| 593 |
@begin{SyntaxText} |
| 594 |
@Leading@Keepnext@;The form of a @nt{pragma} Task_Dispatching_Policy is as follows: |
| 595 |
@end{SyntaxText} |
| 596 |
|
| 597 |
@PragmaSyn`@key{pragma} @prag(Task_Dispatching_Policy)(@SynI{policy_}@Syn2{identifier});' |
| 598 |
|
| 599 |
@begin{SyntaxText} |
| 600 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 601 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The form of a |
| 602 |
@nt{pragma} Priority_Specific_Dispatching is as follows:]} |
| 603 |
@end{SyntaxText} |
| 604 |
|
| 605 |
@ChgRef{Version=[2],Kind=[Added]} |
| 606 |
@ChgAdded{Version=[2],Text=`@AddedPragmaSyn`Version=[2],@key{pragma} @prag<Priority_Specific_Dispatching> (@* |
| 607 |
@ @ @ @ @ @SynI{policy_}@Syn2{identifier}, @SynI{first_priority_}@Syn2{expression}, @SynI{last_priority_}@Syn2{expression});''} |
| 608 |
|
| 609 |
@end{Syntax} |
| 610 |
|
| 611 |
@begin{Resolution} |
| 612 |
|
| 613 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 614 |
@ChgAdded{Version=[2],Text=[The expected type for @SynI{first_priority_}@nt{expression} |
| 615 |
and @SynI{last_priority_}@nt{expression} is Integer.]} |
| 616 |
@end{Resolution} |
| 617 |
|
| 618 |
@begin{Legality} |
| 619 |
|
| 620 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01],ARef=[AI95-00355-01]} |
| 621 |
The @SynI{policy_}@nt{identifier} @Chg{Version=[2],New=[used in a @nt{pragma} |
| 622 |
Task_Dispatching_Policy shall be the name of a task dispatching policy], |
| 623 |
Old=[shall either be FIFO_Within_Priorities or |
| 624 |
an implementation-defined @Syn2{identifier}]}. |
| 625 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 626 |
Text=[Implementation-defined @SynI{policy_}@Syn2{identifier}s allowed |
| 627 |
in a @nt{pragma} Task_Dispatching_Policy.]}]} |
| 628 |
|
| 629 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 630 |
@ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier} |
| 631 |
used in a @nt{pragma} |
| 632 |
Priority_Specific_Dispatching shall be the name of a task dispatching policy.]} |
| 633 |
|
| 634 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 635 |
@ChgAdded{Version=[2],Text=[Both @Syni{first_priority_}@!@nt{expression} and |
| 636 |
@Syni{last_priority_}@!@nt{expression} shall be static expressions in the range |
| 637 |
of System.Any_Priority; @SynI{last_priority_}@!@nt{expression} shall have a |
| 638 |
value greater than or equal to @SynI{first_priority_}@!@nt{expression}.]} |
| 639 |
|
| 640 |
@end{Legality} |
| 641 |
|
| 642 |
@begin{StaticSem} |
| 643 |
|
| 644 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 645 |
@ChgAdded{Version=[2],Text=[@nt{Pragma} Task_Dispatching_Policy specifies the |
| 646 |
single task dispatching policy.]} |
| 647 |
|
| 648 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 649 |
@ChgAdded{Version=[2],Text=[@nt{Pragma} Priority_Specific_Dispatching specifies |
| 650 |
the task dispatching policy for the specified range of priorities. Tasks with |
| 651 |
base priorities within the range of priorities specified in a |
| 652 |
Priority_Specific_Dispatching pragma have their active priorities determined |
| 653 |
according to the specified dispatching policy. Tasks with active priorities |
| 654 |
within the range of priorities specified in a Priority_Specific_Dispatching |
| 655 |
pragma are dispatched according to the specified dispatching policy.]} |
| 656 |
@begin{Reason} |
| 657 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 658 |
@ChgAdded{Version=[2],Text=[Each ready queue is managed by exactly one |
| 659 |
policy. Anything else would be chaos. The ready queue is determined by |
| 660 |
the active priority. However, how the active priority is calculated is |
| 661 |
determined by the policy; in order to break out of this circle, we have |
| 662 |
to say that the active priority is calculated by the method determined |
| 663 |
by the policy of the base priority.]} |
| 664 |
@end{Reason} |
| 665 |
|
| 666 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 667 |
@ChgAdded{Version=[2],Text=[If a partition contains one or more |
| 668 |
Priority_Specific_Dispatching pragmas the dispatching policy for priorities not |
| 669 |
covered by any Priority_Specific_Dispatching pragmas is |
| 670 |
FIFO_Within_Priorities.]} |
| 671 |
|
| 672 |
@end{StaticSem} |
| 673 |
|
| 674 |
@begin{LinkTime} |
| 675 |
|
| 676 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]} |
| 677 |
@PDefn2{Term=[configuration pragma], Sec=(Task_Dispatching_Policy)} |
| 678 |
@PDefn2{Term=[pragma, configuration], Sec=(Task_Dispatching_Policy)} |
| 679 |
A Task_Dispatching_Policy pragma is a configuration pragma.@Chg{Version=[2], |
| 680 |
New=[ A Priority_Specific_Dispatching pragma is a configuration pragma. |
| 681 |
@PDefn2{Term=[configuration pragma], Sec=(Priority_Specific_Dispatching)} |
| 682 |
@PDefn2{Term=[pragma, configuration], Sec=(Priority_Specific_Dispatching)}],Old=[]} |
| 683 |
|
| 684 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 685 |
@ChgAdded{Version=[2],Text=[The priority ranges specified in more than one |
| 686 |
Priority_Specific_Dispatching pragma within the same partition shall not be |
| 687 |
overlapping.]} |
| 688 |
|
| 689 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 690 |
@ChgAdded{Version=[2],Text=[If a partition contains one or more |
| 691 |
Priority_Specific_Dispatching pragmas it shall not contain a |
| 692 |
Task_Dispatching_Policy pragma.]} |
| 693 |
|
| 694 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00333-01]} |
| 695 |
@ChgDeleted{Version=[2],Text=[If the FIFO_Within_Priorities policy is specified |
| 696 |
for a partition, then the Ceiling_Locking policy |
| 697 |
(see @RefSecNum{Priority Ceiling Locking}) shall also be specified for |
| 698 |
the partition.]} |
| 699 |
|
| 700 |
@end{LinkTime} |
| 701 |
|
| 702 |
@begin{RunTime} |
| 703 |
|
| 704 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]} |
| 705 |
@Defn{task dispatching policy} |
| 706 |
@Redundant[A @i{task dispatching policy} specifies the details of task |
| 707 |
dispatching that are not covered by the basic task dispatching model. |
| 708 |
These rules govern when tasks are inserted into and |
| 709 |
deleted from the ready queues@Chg{Version=[2],New=[],Old=[, |
| 710 |
and whether a task is inserted at the head or the tail of the |
| 711 |
queue for its active priority]}.] |
| 712 |
@Chg{Version=[2],New=[A single],Old=[The]} task dispatching policy is |
| 713 |
specified by a Task_Dispatching_Policy @Chg{Version=[2],New=[],Old=[configuration ]}pragma. |
| 714 |
@Chg{Version=[2],New=[Pragma Priority_Specific_Dispatching assigns distinct |
| 715 |
dispatching policies to subranges of System.Any_Priority.], |
| 716 |
Old=[@PDefn{unspecified}If no such pragma appears in any of the program |
| 717 |
units comprising a partition, the task dispatching policy for |
| 718 |
that partition is unspecified.]} |
| 719 |
|
| 720 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 721 |
@ChgAdded{Version=[2],Text=[@PDefn{unspecified}If neither @nt{pragma} applies |
| 722 |
to any of the program units comprising a partition, the task dispatching policy |
| 723 |
for that partition is unspecified.]} |
| 724 |
|
| 725 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 726 |
@ChgAdded{Version=[2],Text=[If a partition contains one or more |
| 727 |
Priority_Specific_Dispatching pragmas a task dispatching point occurs for the |
| 728 |
currently running task of a processor whenever there is a non-empty ready queue |
| 729 |
for that processor with a higher priority than the priority of the running |
| 730 |
task.]} |
| 731 |
|
| 732 |
@begin{Discussion} |
| 733 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 734 |
@ChgAdded{Version=[2],Text=[If we have priority specific dispatching then we |
| 735 |
want preemption across the entire range of priorities. That prevents higher |
| 736 |
priority tasks from being blocked by lower priority tasks that have a |
| 737 |
different policy. On the other hand, if we have a single policy for the |
| 738 |
entire partition, we want the characteristics of that policy to apply for |
| 739 |
preemption; specifically, we may not require any preemption. Note that policy |
| 740 |
Non_Preemptive_FIFO_Within_Priorities is not allowed in a priority specific |
| 741 |
dispatching pragma.]} |
| 742 |
@end{Discussion} |
| 743 |
|
| 744 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]} |
| 745 |
@ChgAdded{Version=[2],Text=[A task that has its base priority changed may move |
| 746 |
from one dispatching policy to another. It is immediately subject |
| 747 |
to the new dispatching policy.]} |
| 748 |
|
| 749 |
@begin{Ramification} |
| 750 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 751 |
@ChgAdded{Version=[2],Text=[Once subject to the new dispatching policy, it |
| 752 |
may be immediately preempted or dispatched, according the rules of the new |
| 753 |
policy.]} |
| 754 |
@end{Ramification} |
| 755 |
|
| 756 |
@ChgNote{The following stuff is moved to the next subclause} |
| 757 |
@begin{NotIso} |
| 758 |
@ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 7 |
| 759 |
through 13 were moved to D.2.3.>}]}@Comment{This message should be deleted if the |
| 760 |
paragraphs are ever renumbered.} |
| 761 |
@end{NotIso} |
| 762 |
|
| 763 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 764 |
@ChgDeleted{Version=[2],Type=[Leading],Text=[The language defines only one task |
| 765 |
dispatching policy, FIFO_Within_Priorities; when this policy is in effect, |
| 766 |
modifications to the ready queues occur only as follows:]} |
| 767 |
|
| 768 |
@begin{itemize} |
| 769 |
|
| 770 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 771 |
@ChgDeleted{Version=[2],Text=[When a blocked task becomes ready, |
| 772 |
it is added at the tail of the ready queue for its active priority.]} |
| 773 |
|
| 774 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 775 |
@ChgDeleted{Version=[2],Text=[When the active priority of a ready task that is |
| 776 |
not running changes, or the setting of its base priority takes effect, the task |
| 777 |
is removed from the ready queue for its old active priority and is added at the |
| 778 |
tail of the ready queue for its new active priority, except in the case where |
| 779 |
the active priority is lowered due to the loss of inherited priority, in which |
| 780 |
case the task is added at the head of the ready queue for its new active |
| 781 |
priority.]} |
| 782 |
|
| 783 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 784 |
@ChgDeleted{Version=[2],Text=[When the setting of the base priority of a |
| 785 |
running task takes effect, the task is added to the tail of the ready queue for |
| 786 |
its active priority.]} |
| 787 |
|
| 788 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 789 |
@ChgDeleted{Version=[2],Text=[When a task executes a @nt{delay_statement} that |
| 790 |
does not result in blocking, it is added to the tail of the ready queue for its |
| 791 |
active priority.]} |
| 792 |
@begin{Ramification} |
| 793 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg]} |
| 794 |
@ChgDeleted{Version=[2],Text=[If the delay does result in blocking, |
| 795 |
the task moves to the @lquotes@;delay queue@rquotes@;, |
| 796 |
not to the ready queue.]} |
| 797 |
@end{Ramification} |
| 798 |
|
| 799 |
@end{itemize} |
| 800 |
|
| 801 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 802 |
@ChgDeleted{Version=[2],Text=[@PDefn{task dispatching point} |
| 803 |
@PDefn{dispatching point} |
| 804 |
Each of the events specified above is a task dispatching point |
| 805 |
(see @RefSecNum{The Task Dispatching Model}).]} |
| 806 |
|
| 807 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 808 |
@ChgDeleted{Version=[2],Text=[In addition, when a task is preempted, it is |
| 809 |
added at the head of the ready queue for its active priority.]} |
| 810 |
|
| 811 |
@end{RunTime} |
| 812 |
|
| 813 |
@begin{ImplReq} |
| 814 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00333-01],ARef=[AI95-00355-01]} |
| 815 |
@ChgAdded{Version=[2],Text=[An implementation shall allow, for a single |
| 816 |
partition, both the locking policy (see @RefSecNum{Priority Ceiling Locking}) |
| 817 |
to be specified as Ceiling_Locking |
| 818 |
and also one or more Priority_Specific_Dispatching pragmas to be given.]} |
| 819 |
@end{ImplReq} |
| 820 |
|
| 821 |
@begin{DocReq} |
| 822 |
|
| 823 |
@begin{NotIso} |
| 824 |
@ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 14 |
| 825 |
through 16 were moved to D.2.3.>}]}@Comment{This message should be deleted if the |
| 826 |
paragraphs are ever renumbered.} |
| 827 |
@end{NotIso} |
| 828 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 829 |
@ChgDeleted{Version=[2],Type=[Leading],Text=[@Defn{priority inversion} |
| 830 |
@i{Priority inversion} is the duration for which a task remains at the |
| 831 |
head of the highest priority ready queue while the processor executes |
| 832 |
a lower priority task. The implementation shall document:]} |
| 833 |
@begin{Itemize} |
| 834 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 835 |
@ChgDeleted{Version=[2],Text=[The maximum priority inversion a user task can experience due to activity |
| 836 |
of the implementation (on behalf of lower priority tasks), and]} |
| 837 |
|
| 838 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 839 |
@ChgDeleted{Version=[2],Text=[whether execution of a task can be preempted by |
| 840 |
the implementation processing of delay |
| 841 |
expirations for lower priority tasks, and if so, for how long.]} |
| 842 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 843 |
Text=[Implementation-defined aspects of priority inversion.]}]} |
| 844 |
@end{Itemize} |
| 845 |
|
| 846 |
@end{DocReq} |
| 847 |
|
| 848 |
@begin{ImplPerm} |
| 849 |
|
| 850 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]} |
| 851 |
Implementations are allowed to define other task dispatching policies, but |
| 852 |
need not support more than one @Chg{Version=[2],New=[task dispatching], |
| 853 |
Old=[such]} policy per partition. |
| 854 |
|
| 855 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]} |
| 856 |
@Chg{Version=[2],New=[An implementation need not support @nt{pragma} |
| 857 |
Priority_Specific_Dispatching if it is infeasible to support it in the |
| 858 |
target environment.], |
| 859 |
Old=[@Redundant[For optimization purposes,] |
| 860 |
an implementation may alter the points at which task dispatching occurs, |
| 861 |
in an implementation defined manner. |
| 862 |
However, a @nt{delay_statement} always corresponds to at least one task |
| 863 |
dispatching point.]} |
| 864 |
|
| 865 |
@ChgImplDef{Version=[2],Kind=[Revised],Text=[Implementation defined task |
| 866 |
dispatching@Chg{Version=[2],New=[ policies],Old=[]}.]} |
| 867 |
|
| 868 |
@end{ImplPerm} |
| 869 |
|
| 870 |
@begin{Notes} |
| 871 |
|
| 872 |
@begin{NotIso} |
| 873 |
@ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 19 |
| 874 |
through 21 were deleted.>}]}@Comment{This message should be deleted if the |
| 875 |
paragraphs are ever renumbered.} |
| 876 |
@end{NotIso} |
| 877 |
|
| 878 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 879 |
@ChgDeleted{Version=[2],Text=[If the active priority of a running task is |
| 880 |
lowered due to loss of inherited priority (as it is on completion of a |
| 881 |
protected operation) and there is a ready task of the same active priority that |
| 882 |
is not running, the running task continues to run (provided that there is no |
| 883 |
higher priority task).]} |
| 884 |
|
| 885 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 886 |
@ChgDeleted{Version=[2],Text=[The setting of a task's base priority as a result |
| 887 |
of a call to Set_Priority does not always take effect immediately when |
| 888 |
Set_Priority is called. The effect of setting the task's base priority is |
| 889 |
deferred while the affected task performs a protected action.]} |
| 890 |
|
| 891 |
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]} |
| 892 |
@ChgDeleted{Version=[2],Text=[Setting the base priority of a ready task causes |
| 893 |
the task to move to the end of the queue for its active priority, |
| 894 |
regardless of whether the active priority of the task actually changes.]} |
| 895 |
|
| 896 |
@end{Notes} |
| 897 |
|
| 898 |
@begin{Extend95} |
| 899 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]} |
| 900 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 901 |
@B[Amendment Correction:] It is no longer required to specify Ceiling_Locking |
| 902 |
with the language-defined task dispatching policies; we only require that |
| 903 |
implementations @i<allow> them to be used together.]} |
| 904 |
|
| 905 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 906 |
@ChgAdded{Version=[2],Text=[@key{Pragma} Priority_Specific_Dispatching is |
| 907 |
new; it allows specifying different policies for different priorities.]} |
| 908 |
@end{Extend95} |
| 909 |
|
| 910 |
@begin{DiffWord95} |
| 911 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]} |
| 912 |
@ChgAdded{Version=[2],Text=[Clarified that an implementation need support |
| 913 |
only one task dispatching policy (of any kind, language-defined or otherwise) |
| 914 |
per partition.]} |
| 915 |
|
| 916 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 917 |
@ChgAdded{Version=[2],Text=[This description is simplified to describe only |
| 918 |
the rules for the Task_Dispatching_Policy pragma that are common to |
| 919 |
all policies. In particular, rules about preemption are moved elsewhere. This |
| 920 |
makes it easier to add other policies (which may not involve preemption).]} |
| 921 |
@end{DiffWord95} |
| 922 |
|
| 923 |
|
| 924 |
@LabeledAddedSubClause{Version=[2],Name=[Preemptive Dispatching]} |
| 925 |
|
| 926 |
@begin{Intro} |
| 927 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 928 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause defines a preemptive task |
| 929 |
dispatching policy.]]} |
| 930 |
@end{Intro} |
| 931 |
|
| 932 |
@begin{StaticSem} |
| 933 |
|
| 934 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 935 |
@ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier} |
| 936 |
FIFO_Within_Priorities is a task dispatching policy.]} |
| 937 |
|
| 938 |
@end{StaticSem} |
| 939 |
|
| 940 |
@begin{RunTime} |
| 941 |
|
| 942 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 943 |
@ChgAdded{Version=[2],Text=[When FIFO_Within_Priorities is in effect, |
| 944 |
modifications to the ready queues occur only as follows:]} |
| 945 |
|
| 946 |
@begin{itemize} |
| 947 |
|
| 948 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 949 |
@ChgAdded{Version=[2],Text=[When a blocked task becomes ready, it is added at |
| 950 |
the tail of the ready queue for its active priority.]} |
| 951 |
|
| 952 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 953 |
@ChgAdded{Version=[2],Text=[When the active priority of a ready task that is |
| 954 |
not running changes, or the setting of its base |
| 955 |
priority takes effect, the task is removed from the ready queue for |
| 956 |
its old active priority and is added at the tail of the ready queue for its new |
| 957 |
active priority, except in the case where the active priority is lowered due to |
| 958 |
the loss of inherited priority, in which case the task is added at the |
| 959 |
head of the ready queue for its new active priority.]} |
| 960 |
|
| 961 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 962 |
@ChgAdded{Version=[2],Text=[When the setting of the base priority of a running task takes effect, the |
| 963 |
task is added to the tail of the ready queue for its active priority.]} |
| 964 |
|
| 965 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 966 |
@ChgAdded{Version=[2],Text=[When a task executes a @nt{delay_statement} that |
| 967 |
does not result in blocking, it is added to the tail of the ready queue for |
| 968 |
its active priority.]} |
| 969 |
@begin{Ramification} |
| 970 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 971 |
@ChgAdded{Version=[2],Text=[If the delay does result in blocking, |
| 972 |
the task moves to the @lquotes@;delay queue@rquotes@;, |
| 973 |
not to the ready queue.]} |
| 974 |
@end{Ramification} |
| 975 |
|
| 976 |
@end{itemize} |
| 977 |
|
| 978 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 979 |
@ChgAdded{Version=[2],Text=[@PDefn{task dispatching point} |
| 980 |
@PDefn{dispatching point} |
| 981 |
Each of the events specified above is a task dispatching point |
| 982 |
(see @RefSecNum{The Task Dispatching Model}).]} |
| 983 |
|
| 984 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 985 |
@ChgAdded{Version=[2],Text=[A task dispatching point occurs for the currently |
| 986 |
running task of a processor whenever there is a nonempty ready queue for that |
| 987 |
processor with a higher priority than the priority of the running task. The |
| 988 |
currently running task is said to be @i<preempted> and it is added at the head |
| 989 |
of the ready queue for its active priority.@Defn2{Term=[preempt],Sec=[a running task]}]} |
| 990 |
|
| 991 |
@end{RunTime} |
| 992 |
|
| 993 |
@begin{ImplReq} |
| 994 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]} |
| 995 |
@ChgAdded{Version=[2],Text=[An implementation shall allow, for a single |
| 996 |
partition, both the task dispatching policy to be specified as |
| 997 |
FIFO_Within_Priorities and also the locking policy (see |
| 998 |
@RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]} |
| 999 |
@begin{Reason} |
| 1000 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1001 |
@ChgAdded{Version=[2],Text=[This is the preferred combination of the |
| 1002 |
FIFO_Within_Priorities policy with a locking policy, and we want that |
| 1003 |
combination to be portable.]} |
| 1004 |
@end{Reason} |
| 1005 |
@end{ImplReq} |
| 1006 |
|
| 1007 |
@begin{DocReq} |
| 1008 |
|
| 1009 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 1010 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn{priority inversion} |
| 1011 |
@i{Priority inversion} is the duration for which a task remains at the |
| 1012 |
head of the highest priority nonempty ready queue while the processor executes |
| 1013 |
a lower priority task. The implementation shall document:]} |
| 1014 |
|
| 1015 |
@begin{Itemize} |
| 1016 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1017 |
@ChgAdded{Version=[2],Text=[The maximum priority inversion a user task |
| 1018 |
can experience due to activity |
| 1019 |
of the implementation (on behalf of lower priority tasks), and]} |
| 1020 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 1021 |
Text=[The maximum priority inversion a user task can experience from |
| 1022 |
the implementation.]}]} |
| 1023 |
|
| 1024 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1025 |
@ChgAdded{Version=[2],Text=[whether execution of a task can be preempted |
| 1026 |
by the implementation processing of delay |
| 1027 |
expirations for lower priority tasks, and if so, for how long.]} |
| 1028 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 1029 |
Text=[The amount of time that a task can be preempted for processing on |
| 1030 |
behalf of lower-priority tasks.]}]} |
| 1031 |
@end{Itemize} |
| 1032 |
|
| 1033 |
@end{DocReq} |
| 1034 |
|
| 1035 |
@begin{Notes} |
| 1036 |
|
| 1037 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 1038 |
@ChgAdded{Version=[2],Text=[If the active priority of a running task is |
| 1039 |
lowered due to loss of |
| 1040 |
inherited priority (as it is on completion of a protected |
| 1041 |
operation) and there is a ready task of the same active priority |
| 1042 |
that is not running, |
| 1043 |
the running task continues to run (provided that there is no higher |
| 1044 |
priority task).]} |
| 1045 |
|
| 1046 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 1047 |
@ChgAdded{Version=[2],Text=[Setting the base priority of a ready task causes |
| 1048 |
the task to move to the tail of the queue for its active priority, |
| 1049 |
regardless of whether the active priority of the task actually changes.]} |
| 1050 |
|
| 1051 |
@end{Notes} |
| 1052 |
|
| 1053 |
@begin{DiffWord95} |
| 1054 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 1055 |
@ChgAdded{Version=[2],Text=[This subclause is new; it mainly consists of |
| 1056 |
text that was found in @RefSecNum{The Task Dispatching Model} and |
| 1057 |
@RefSecNum{Task Dispatching Pragmas} in Ada 95. This was |
| 1058 |
separated out so the definition of additional policies was easier.]} |
| 1059 |
|
| 1060 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]} |
| 1061 |
@ChgAdded{Version=[2],Text=[We require that implementations allow |
| 1062 |
this policy and Ceiling_Locking together.]} |
| 1063 |
|
| 1064 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1065 |
@ChgAdded{Version=[2],Text=[We explicitly defined FIFO_Within_Priorities |
| 1066 |
to be a task dispatching policy.]} |
| 1067 |
@end{DiffWord95} |
| 1068 |
|
| 1069 |
|
| 1070 |
@LabeledAddedSubClause{Version=[2],Name=[Non-Preemptive Dispatching]} |
| 1071 |
|
| 1072 |
@begin{Intro} |
| 1073 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]} |
| 1074 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause defines a non-preemptive task |
| 1075 |
dispatching policy.]]} |
| 1076 |
@end{Intro} |
| 1077 |
|
| 1078 |
@begin{StaticSem} |
| 1079 |
|
| 1080 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01],ARef=[AI95-00355-01]} |
| 1081 |
@ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier} |
| 1082 |
Non_Preemptive_FIFO_Within_Priorities is a task dispatching policy.]} |
| 1083 |
|
| 1084 |
@end{StaticSem} |
| 1085 |
|
| 1086 |
@begin{Legality} |
| 1087 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1088 |
@ChgAdded{Version=[2],Text=[Non_Preemptive_FIFO_Within_Priorities shall not be |
| 1089 |
specified as the @SynI{policy_}@nt{identifier} of @nt{pragma} |
| 1090 |
Priority_Specific_Dispatching (see |
| 1091 |
@RefSecNum{Task Dispatching Pragmas}).]} |
| 1092 |
|
| 1093 |
@begin{Reason} |
| 1094 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1095 |
@ChgAdded{Version=[2],Text=[The non-preemptive nature of this policy could |
| 1096 |
cause the policies of higher priority tasks to malfunction, missing deadlines |
| 1097 |
and having unlimited priority inversion. That would render the use of such |
| 1098 |
policies impotent and misleading. As such, this policy only makes sense |
| 1099 |
for a complete system.]} |
| 1100 |
@end{Reason} |
| 1101 |
@end{Legality} |
| 1102 |
|
| 1103 |
@begin{RunTime} |
| 1104 |
|
| 1105 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]} |
| 1106 |
@ChgAdded{Version=[2],Text=[When Non_Preemptive_FIFO_Within_Priorities is in |
| 1107 |
effect, modifications to the ready queues occur only as follows:]} |
| 1108 |
|
| 1109 |
@begin{itemize} |
| 1110 |
|
| 1111 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]} |
| 1112 |
@ChgAdded{Version=[2],Text=[When a blocked task becomes ready, it is added at |
| 1113 |
the tail of the ready queue for its active priority.]} |
| 1114 |
|
| 1115 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1116 |
@ChgAdded{Version=[2],Text=[When the active priority of a ready task that is |
| 1117 |
not running changes, or the setting of its base |
| 1118 |
priority takes effect, the task is removed from the ready queue for |
| 1119 |
its old active priority and is added at the tail of the ready queue for its new |
| 1120 |
active priority.]} |
| 1121 |
|
| 1122 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1123 |
@ChgAdded{Version=[2],Text=[When the setting of the base priority of a running task takes effect, the |
| 1124 |
task is added to the tail of the ready queue for its active priority.]} |
| 1125 |
|
| 1126 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1127 |
@ChgAdded{Version=[2],Text=[When a task executes a @nt{delay_statement} that |
| 1128 |
does not result in blocking, it is added to the tail of the ready queue for |
| 1129 |
its active priority.]} |
| 1130 |
@begin{Ramification} |
| 1131 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1132 |
@ChgAdded{Version=[2],Text=[If the delay does result in blocking, |
| 1133 |
the task moves to the @lquotes@;delay queue@rquotes@;, |
| 1134 |
not to the ready queue.]} |
| 1135 |
@end{Ramification} |
| 1136 |
|
| 1137 |
@end{itemize} |
| 1138 |
|
| 1139 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1140 |
@ChgAdded{Version=[2],Text=[For this policy, a non-blocking @nt{delay_statement} |
| 1141 |
is the only non-blocking event that is a task dispatching point (see |
| 1142 |
@RefSecNum{The Task Dispatching Model}).@PDefn{task dispatching point} |
| 1143 |
@PDefn{dispatching point}]} |
| 1144 |
|
| 1145 |
@end{RunTime} |
| 1146 |
|
| 1147 |
@begin{ImplReq} |
| 1148 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]} |
| 1149 |
@ChgAdded{Version=[2],Text=[An implementation shall allow, for a single |
| 1150 |
partition, both the task dispatching policy to be specified as |
| 1151 |
Non_Preemptive_FIFO_Within_Priorities and also the locking policy (see |
| 1152 |
@RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]} |
| 1153 |
@begin{Reason} |
| 1154 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1155 |
@ChgAdded{Version=[2],Text=[This is the preferred combination of the |
| 1156 |
Non_Preemptive_FIFO_Within_Priorities policy with a locking policy, and we |
| 1157 |
want that combination to be portable.]} |
| 1158 |
@end{Reason} |
| 1159 |
@end{ImplReq} |
| 1160 |
|
| 1161 |
@begin{ImplPerm} |
| 1162 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]} |
| 1163 |
@ChgAdded{Version=[2],Text=[Since implementations are allowed to round all |
| 1164 |
ceiling priorities in subrange System.Priority to System.Priority'Last (see |
| 1165 |
@RefSecNum{Priority Ceiling Locking}), an implementation may allow a task to |
| 1166 |
execute within a protected object without raising its active priority provided |
| 1167 |
the associated protected unit does not contain pragma Interrupt_Priority, |
| 1168 |
Interrupt_Handler, or Attach_Handler.]} |
| 1169 |
|
| 1170 |
@end{ImplPerm} |
| 1171 |
|
| 1172 |
@begin{Extend95} |
| 1173 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01],ARef=[AI95-00355-01]} |
| 1174 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 1175 |
Policy Non_Preemptive_FIFO_Within_Priorities is new.]} |
| 1176 |
@end{Extend95} |
| 1177 |
|
| 1178 |
|
| 1179 |
@LabeledAddedSubClause{Version=[2],Name=[Round Robin Dispatching]} |
| 1180 |
|
| 1181 |
@begin{Intro} |
| 1182 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1183 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause defines the task dispatching |
| 1184 |
policy Round_Robin_Within_Priorities and the package Round_Robin.]]} |
| 1185 |
@end{Intro} |
| 1186 |
|
| 1187 |
@begin{StaticSem} |
| 1188 |
|
| 1189 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1190 |
@ChgAdded{Version=[2],Text=[The @SynI{policy}_@nt{identifier} |
| 1191 |
Round_Robin_Within_Priorities is a task dispatching policy.]} |
| 1192 |
|
| 1193 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1194 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 1195 |
language-defined library package exists:]} |
| 1196 |
@begin{Example} |
| 1197 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1198 |
@ChgAdded{Version=[2],Text=[@key{with} System; |
| 1199 |
@key{with} Ada.Real_Time; |
| 1200 |
@key{package} Ada.Dispatching.Round_Robin @key{is}@ChildUnit{Parent=[Ada.Dispatching],Child=[Round_Robin]} |
| 1201 |
@AdaObjDefn{Default_Quantum} : @key{constant} Ada.Real_Time.Time_Span := |
| 1202 |
@RI[implementation-defined]; |
| 1203 |
@key{procedure} @AdaSubDefn{Set_Quantum} (Pri : @key{in} System.Priority; |
| 1204 |
Quantum : @key{in} Ada.Real_Time.Time_Span); |
| 1205 |
@key{procedure} @AdaSubDefn{Set_Quantum} (Low, High : @key{in} System.Priority; |
| 1206 |
Quantum : @key{in} Ada.Real_Time.Time_Span); |
| 1207 |
@key{function} @AdaSubDefn{Actual_Quantum} (Pri : System.Priority) @key{return} Ada.Real_Time.Time_Span; |
| 1208 |
@key{function} @AdaSubDefn{Is_Round_Robin} (Pri : System.Priority) @key{return} Boolean; |
| 1209 |
@key{end} Ada.Dispatching.Round_Robin;]} |
| 1210 |
@end{Example} |
| 1211 |
@ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 1212 |
Text=[The value of Default_Quantum in Dispatching.Round_Robin.]}]} |
| 1213 |
|
| 1214 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1215 |
@ChgAdded{Version=[2],Text=[When task dispatching policy Round_Robin_Within_Priorities is the single |
| 1216 |
policy in effect for a partition, each task with priority in the range of |
| 1217 |
System.Interrupt_Priority is dispatched according to policy |
| 1218 |
FIFO_Within_Priorities.]} |
| 1219 |
|
| 1220 |
@end{StaticSem} |
| 1221 |
|
| 1222 |
@begin{Runtime} |
| 1223 |
|
| 1224 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1225 |
@ChgAdded{Version=[2],Text=[The procedures Set_Quantum set the required Quantum |
| 1226 |
value for a single priority level Pri or a range of priority levels Low .. High. |
| 1227 |
If no quantum is set for a Round Robin priority level, Default_Quantum is used.]} |
| 1228 |
|
| 1229 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1230 |
@ChgAdded{Version=[2],Text=[The function Actual_Quantum returns the actual |
| 1231 |
quantum used by the implementation for the priority level Pri.]} |
| 1232 |
|
| 1233 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1234 |
@ChgAdded{Version=[2],Text=[The function Is_Round_Robin returns True if |
| 1235 |
priority Pri is covered by task dispatching policy |
| 1236 |
Round_Robin_Within_Priorities; otherwise it returns False.]} |
| 1237 |
|
| 1238 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1239 |
@ChgAdded{Version=[2],Text=[A call of Actual_Quantum or Set_Quantum raises |
| 1240 |
exception Dispatching.Dispatching_Policy_Error if a predefined policy other |
| 1241 |
than Round_Robin_Within_Priorities applies to the specified priority |
| 1242 |
or any of the priorities in the specified range.]} |
| 1243 |
|
| 1244 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1245 |
@ChgAdded{Version=[2],Type=[Leading],Text=[For Round_Robin_Within_Priorities, |
| 1246 |
the dispatching rules for FIFO_Within_Priorities apply with the following |
| 1247 |
additional rules:]} |
| 1248 |
|
| 1249 |
@begin{Itemize} |
| 1250 |
|
| 1251 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1252 |
@ChgAdded{Version=[2],Text=[When a task is added or moved to the tail of the |
| 1253 |
ready queue for its base priority, it has an execution time budget equal to the |
| 1254 |
quantum for that priority level. This will also occur when a blocked task |
| 1255 |
becomes executable again.]} |
| 1256 |
|
| 1257 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1258 |
@ChgAdded{Version=[2],Text=[When a task is preempted (by a higher priority |
| 1259 |
task) and is added to the head of the ready queue for its priority level, it |
| 1260 |
retains its remaining budget.]} |
| 1261 |
|
| 1262 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1263 |
@ChgAdded{Version=[2],Text=[While a task is executing, its budget is decreased |
| 1264 |
by the amount of execution time it uses. The accuracy of this accounting is the |
| 1265 |
same as that for execution time clocks (see @RefSecNum{Execution Time}).]} |
| 1266 |
@begin{Ramification} |
| 1267 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1268 |
@ChgAdded{Version=[2],Text=[Note that this happens even when the task |
| 1269 |
is executing at a higher, inherited priority, and even if that higher |
| 1270 |
priority is dispatched by a different policy than round robin.]} |
| 1271 |
@end{Ramification} |
| 1272 |
|
| 1273 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1274 |
@ChgAdded{Version=[2],Text=[When a task has exhausted its budget and is without |
| 1275 |
an inherited priority (and is not executing within a protected operation), it |
| 1276 |
is moved to the tail of the ready queue for its priority level. This is a task |
| 1277 |
dispatching point.]} |
| 1278 |
|
| 1279 |
@begin{Ramification} |
| 1280 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1281 |
@ChgAdded{Version=[2],Text=[In this case, it will be given |
| 1282 |
a budget as described in the first bullet.]} |
| 1283 |
|
| 1284 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1285 |
@ChgAdded{Version=[2],Text=[The rules for FIFO_Within_Priority (to which |
| 1286 |
these bullets are added) say that a task that has its base priority set to a |
| 1287 |
Round Robin priority is moved to the tail of the ready queue for its new |
| 1288 |
priority level, and then will be given a budget as described in the first |
| 1289 |
bullet. That happens whether or not the task's original base priority was |
| 1290 |
a Round Robin priority.]} |
| 1291 |
@end{Ramification} |
| 1292 |
|
| 1293 |
@end{Itemize} |
| 1294 |
|
| 1295 |
@end{Runtime} |
| 1296 |
|
| 1297 |
@begin{ImplReq} |
| 1298 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01],ARef=[AI95-00355-01]} |
| 1299 |
@ChgAdded{Version=[2],Text=[An implementation shall allow, for a single |
| 1300 |
partition, both the task dispatching policy to be specified as |
| 1301 |
Round_Robin_Within_Priorities and also the locking policy (see |
| 1302 |
@RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]} |
| 1303 |
@begin{Reason} |
| 1304 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1305 |
@ChgAdded{Version=[2],Text=[This is the preferred combination of the |
| 1306 |
Round_Robin_Within_Priorities policy with a locking policy, and we |
| 1307 |
want that combination to be portable.]} |
| 1308 |
@end{Reason} |
| 1309 |
@end{ImplReq} |
| 1310 |
|
| 1311 |
@begin{DocReq} |
| 1312 |
|
| 1313 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1314 |
@ChgAdded{Version=[2],Text=[An implementation shall document the quantum values |
| 1315 |
supported.]} |
| 1316 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 1317 |
Text=[The quantum values supported for round robin dispatching.]}]} |
| 1318 |
|
| 1319 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1320 |
@ChgAdded{Version=[2],Text=[An implementation shall document the accuracy with |
| 1321 |
which it detects the exhaustion of the budget of a task.]} |
| 1322 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 1323 |
Text=[The accuracy of the detection of the exhaustion of the budget of a task |
| 1324 |
for round robin dispatching.]}]} |
| 1325 |
|
| 1326 |
@end{DocReq} |
| 1327 |
|
| 1328 |
@begin{Notes} |
| 1329 |
|
| 1330 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1331 |
@ChgAdded{Version=[2],Text=[Due to implementation constraints, the quantum |
| 1332 |
value returned by Actual_Quantum might not be identical to that set with |
| 1333 |
Set_Quantum.]} |
| 1334 |
|
| 1335 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1336 |
@ChgAdded{Version=[2],Text=[A task that executes continuously with an inherited |
| 1337 |
priority will not be subject to round robin dispatching.]} |
| 1338 |
|
| 1339 |
@end{Notes} |
| 1340 |
|
| 1341 |
@begin{Extend95} |
| 1342 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 1343 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 1344 |
Policy Round_Robin_Within_Priorities and package |
| 1345 |
Dispatching.Round_Robin are new.]} |
| 1346 |
@end{Extend95} |
| 1347 |
|
| 1348 |
|
| 1349 |
@RMNewPage@Comment{For printed Ada 2005 RM} |
| 1350 |
@LabeledAddedSubClause{Version=[2],Name=[Earliest Deadline First Dispatching]} |
| 1351 |
|
| 1352 |
@begin{Intro} |
| 1353 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1354 |
@ChgAdded{Version=[2],Text=[The deadline of a task is an indication of the |
| 1355 |
urgency of the task; it represents a point on an ideal physical time line. |
| 1356 |
The deadline might affect how resources are allocated to the task.]} |
| 1357 |
|
| 1358 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1359 |
@ChgAdded{Version=[2],Text=[This clause defines a package for representing the |
| 1360 |
deadline of a task and a dispatching policy that defines Earliest Deadline |
| 1361 |
First (EDF) dispatching. A pragma is defined to assign an initial deadline to a |
| 1362 |
task.]} |
| 1363 |
|
| 1364 |
@begin{Discussion} |
| 1365 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1366 |
@ChgAdded{Version=[2],Text=[This pragma is the only way of assigning an |
| 1367 |
initial deadline to a task so that its activation can be controlled by EDF |
| 1368 |
scheduling. This is similar to the way pragma Priority is used to give an |
| 1369 |
initial priority to a task.]} |
| 1370 |
@end{Discussion} |
| 1371 |
|
| 1372 |
@end{Intro} |
| 1373 |
|
| 1374 |
@begin{MetaRules} |
| 1375 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1376 |
@ChgAdded{Version=[2],Text=[To predict the behavior of a multi-tasking program |
| 1377 |
it is necessary to control access to the processor which is preemptive, and |
| 1378 |
shared objects which are usually non-preemptive and embodied in protected |
| 1379 |
objects. Two common dispatching policies for the processor are fixed priority |
| 1380 |
and EDF. The most effective control over shared objects is via preemption |
| 1381 |
levels. With a pure priority scheme a single notion of priority is used for |
| 1382 |
processor dispatching and preemption levels. With EDF and similar schemes |
| 1383 |
priority is used for preemption levels (only), with another measure used for |
| 1384 |
dispatching. T.P. Baker showed (@i<Real-Time Systems>, March 1991, vol. 3, num. |
| 1385 |
1, @i<Stack-Based Scheduling of Realtime Processes>) that for EDF a newly |
| 1386 |
released task should only preempt the currently running task if it has an |
| 1387 |
earlier deadline and a higher preemption level than any currently |
| 1388 |
@lquotes@;locked@rquotes protected object. The rules of this clause implement |
| 1389 |
this scheme including the case where the newly released task should execute |
| 1390 |
before some existing tasks but not preempt the currently executing task.]} |
| 1391 |
@end{MetaRules} |
| 1392 |
|
| 1393 |
@begin{Syntax} |
| 1394 |
|
| 1395 |
@begin{SyntaxText} |
| 1396 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1397 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The form of a |
| 1398 |
@nt{pragma} Relative_Deadline is as follows:]} |
| 1399 |
@end{SyntaxText} |
| 1400 |
|
| 1401 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1402 |
@ChgAdded{Version=[2],Text=`@AddedPragmaSyn`Version=[2],@key{pragma} @prag<Relative_Deadline> (@SynI{relative_deadline_}@Syn2{expression});''} |
| 1403 |
|
| 1404 |
@end{Syntax} |
| 1405 |
|
| 1406 |
@begin{Resolution} |
| 1407 |
|
| 1408 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1409 |
@ChgAdded{Version=[2],Text=[The expected type for |
| 1410 |
@SynI{relative_deadline_}@nt{expression} is Real_Time.Time_Span.]} |
| 1411 |
|
| 1412 |
@end{Resolution} |
| 1413 |
|
| 1414 |
@begin{Legality} |
| 1415 |
|
| 1416 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1417 |
@ChgAdded{Version=[2],Text=[A Relative_Deadline pragma is allowed only |
| 1418 |
immediately within a @nt{task_definition} or the @nt{declarative_part} of a |
| 1419 |
@nt{subprogram_body}. At most one such pragma shall appear within a given |
| 1420 |
construct.]} |
| 1421 |
|
| 1422 |
@end{Legality} |
| 1423 |
|
| 1424 |
@begin{StaticSem} |
| 1425 |
|
| 1426 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1427 |
@ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier} |
| 1428 |
EDF_Across_Priorities is a task dispatching policy.]} |
| 1429 |
|
| 1430 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1431 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 1432 |
language-defined library package exists:]} |
| 1433 |
@begin{Example} |
| 1434 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1435 |
@ChgAdded{Version=[2],Text=[@key{with} Ada.Real_Time; |
| 1436 |
@key{with} Ada.Task_Identification; |
| 1437 |
@key{package} Ada.Dispatching.EDF @key{is}@ChildUnit{Parent=[Ada.Dispatching],Child=[EDF]} |
| 1438 |
@key{subtype} @AdaSubtypeDefn{Name=[Deadline],Of=[Time]} @key{is} Ada.Real_Time.Time; |
| 1439 |
@AdaObjDefn{Default_Deadline} : @key{constant} Deadline := |
| 1440 |
Ada.Real_Time.Time_Last; |
| 1441 |
@key{procedure} @AdaSubDefn{Set_Deadline} (D : @key{in} Deadline; |
| 1442 |
T : @key{in} Ada.Task_Identification.Task_Id := |
| 1443 |
Ada.Task_Identification.Current_Task); |
| 1444 |
@key{procedure} @AdaSubDefn{Delay_Until_And_Set_Deadline} ( |
| 1445 |
Delay_Until_Time : @key{in} Ada.Real_Time.Time; |
| 1446 |
Deadline_Offset : @key{in} Ada.Real_Time.Time_Span); |
| 1447 |
@key{function} @AdaSubDefn{Get_Deadline} (T : Ada.Task_Identification.Task_Id := |
| 1448 |
Ada.Task_Identification.Current_Task) @key{return} Deadline; |
| 1449 |
@key{end} Ada.Dispatching.EDF;]} |
| 1450 |
@end{Example} |
| 1451 |
|
| 1452 |
@end{StaticSem} |
| 1453 |
|
| 1454 |
@begin{LinkTime} |
| 1455 |
|
| 1456 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1457 |
@ChgAdded{Version=[2],Text=[If the EDF_Across_Priorities policy is specified |
| 1458 |
for a partition, then the Ceiling_Locking policy (see |
| 1459 |
@RefSecNum{Priority Ceiling Locking}) shall also be |
| 1460 |
specified for the partition.]} |
| 1461 |
|
| 1462 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1463 |
@ChgAdded{Version=[2],Text=[If the EDF_Across_Priorities policy appears in a |
| 1464 |
Priority_Specific_Dispatching pragma |
| 1465 |
(see @RefSecNum{Task Dispatching Pragmas}) |
| 1466 |
in a partition, then the |
| 1467 |
Ceiling_Locking policy (see @RefSecNum{Priority Ceiling Locking}) shall also |
| 1468 |
be specified for the partition.]} |
| 1469 |
|
| 1470 |
@begin{Reason} |
| 1471 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1472 |
@ChgAdded{Version=[2],Text=[Unlike the other language-defined dispatching |
| 1473 |
policies, the semantic description of EDF_Across_Priorities assumes |
| 1474 |
Ceiling_Locking (and a ceiling priority) in order to make the mapping between |
| 1475 |
deadlines and priorities work. Thus, we require both policies to be specified |
| 1476 |
if EDF is used in the partition.]} |
| 1477 |
@end{Reason} |
| 1478 |
|
| 1479 |
@end{LinkTime} |
| 1480 |
|
| 1481 |
@begin{RunTime} |
| 1482 |
|
| 1483 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1484 |
@ChgAdded{Version=[2],Text=[A Relative_Deadline pragma has no effect if it |
| 1485 |
occurs in the @nt{declarative_part} of the @nt{subprogram_body} of a |
| 1486 |
subprogram other than the main subprogram.]} |
| 1487 |
|
| 1488 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1489 |
@ChgAdded{Version=[2],Text=[The initial absolute deadline of a task containing |
| 1490 |
pragma Relative_Deadline is the value of Real_Time.Clock + |
| 1491 |
@SynI{relative_deadline_}@nt{expression}, where the call of Real_Time.Clock is made |
| 1492 |
between task creation and the start of its activation. If there is no |
| 1493 |
Relative_Deadline pragma then the initial absolute deadline of a task is the |
| 1494 |
value of Default_Deadline. @Redundant[The environment task is also given |
| 1495 |
an initial deadline by this rule.]]} |
| 1496 |
|
| 1497 |
@begin{TheProof} |
| 1498 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1499 |
@ChgAdded{Version=[2],Text=[The environment task is a normal task by |
| 1500 |
@RefSecNum{Program Execution}, so of course this rule applies to it.]} |
| 1501 |
@end{TheProof} |
| 1502 |
|
| 1503 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1504 |
@ChgAdded{Version=[2],Text=[The procedure Set_Deadline changes the absolute |
| 1505 |
deadline of the task to D. The function Get_Deadline returns the absolute |
| 1506 |
deadline of the task.]} |
| 1507 |
|
| 1508 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1509 |
@ChgAdded{Version=[2],Text=[The procedure Delay_Until_And_Set_Deadline delays |
| 1510 |
the calling task until time Delay_Until_Time. When the task becomes runnable |
| 1511 |
again it will have deadline Delay_Until_Time + Deadline_Offset.]} |
| 1512 |
|
| 1513 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1514 |
@ChgAdded{Version=[2],Text=[On a system with a single processor, the setting of |
| 1515 |
the deadline of a task to the new value occurs immediately at the first point |
| 1516 |
that is outside the execution of a protected action. If the task is currently |
| 1517 |
on a ready queue it is removed and re-entered on to the ready queue determined |
| 1518 |
by the rules defined below.]} |
| 1519 |
|
| 1520 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1521 |
@ChgAdded{Version=[2],Text=[When EDF_Across_Priorities is specified for |
| 1522 |
priority range @i<Low>..@i<High> all ready queues in this range are ordered by |
| 1523 |
deadline. The task at the head of a queue is the one with the earliest |
| 1524 |
deadline.]} |
| 1525 |
|
| 1526 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1527 |
@ChgAdded{Version=[2],Type=[Leading],Text=[A task dispatching point occurs |
| 1528 |
for the currently running task @i<T> to |
| 1529 |
which policy EDF_Across_Priorities applies:]} |
| 1530 |
|
| 1531 |
@begin{Itemize} |
| 1532 |
|
| 1533 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1534 |
@ChgAdded{Version=[2],Text=[when a change to the deadline of @i<T> occurs;]} |
| 1535 |
|
| 1536 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1537 |
@ChgAdded{Version=[2],Text=[there is a task on the ready queue for the |
| 1538 |
active priority of @i<T> with a deadline earlier than the deadline of @i<T>; or]} |
| 1539 |
|
| 1540 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1541 |
@ChgAdded{Version=[2],Text=[there is a non-empty ready queue for that processor |
| 1542 |
with a higher priority than the active priority of the running task.]} |
| 1543 |
|
| 1544 |
@end{Itemize} |
| 1545 |
|
| 1546 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1547 |
@ChgAdded{Version=[2],Text=[In these cases, the currently running task is said |
| 1548 |
to be preempted and is returned to |
| 1549 |
the ready queue for its active priority.]} |
| 1550 |
|
| 1551 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1552 |
@ChgAdded{Version=[2],Type=[Leading],Text=[For a task @i<T> to which policy |
| 1553 |
EDF_Across_Priorities applies, the base priority is not a source of |
| 1554 |
priority inheritance; the active priority when first activated or |
| 1555 |
while it is blocked is defined as the maximum of the following:]} |
| 1556 |
|
| 1557 |
@begin{Itemize} |
| 1558 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1559 |
@ChgAdded{Version=[2],Text=[the lowest priority in the range specified as |
| 1560 |
EDF_Across_Priorities that includes the base priority of @i<T>;]} |
| 1561 |
|
| 1562 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1563 |
@ChgAdded{Version=[2],Text=[the priorities, if any, currently inherited by |
| 1564 |
@i<T>;]} |
| 1565 |
|
| 1566 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1567 |
@ChgAdded{Version=[2],Text=[the highest priority @i<P>, if any, less than the |
| 1568 |
base priority of @i<T> such that one or more tasks are executing within a |
| 1569 |
protected object with ceiling priority @i<P> and task @i<T> |
| 1570 |
has an earlier deadline than all such tasks.]} |
| 1571 |
@end{Itemize} |
| 1572 |
|
| 1573 |
@begin{Ramification} |
| 1574 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1575 |
@ChgAdded{Version=[2],Text=[The active priority of @i<T> might be lower than |
| 1576 |
its base priority.]} |
| 1577 |
@end{Ramification} |
| 1578 |
|
| 1579 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1580 |
@ChgAdded{Version=[2],Text=[When a task @i<T> is first activated or becomes |
| 1581 |
unblocked, it is added to the ready queue corresponding to this active |
| 1582 |
priority. Until it becomes blocked again, the active priority of @i<T> |
| 1583 |
remains no less than this value; it will exceed this value only while it is |
| 1584 |
inheriting a higher priority.]} |
| 1585 |
|
| 1586 |
@begin{Discussion} |
| 1587 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1588 |
@ChgAdded{Version=[2],Text=[These rules ensure that a task executing in |
| 1589 |
a protected object is preempted only by a task with a shorter deadline and a |
| 1590 |
higher base priority. This matches the traditional preemption level |
| 1591 |
description without the need to define a new kind of protected object |
| 1592 |
locking.]} |
| 1593 |
@end{Discussion} |
| 1594 |
|
| 1595 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1596 |
@ChgAdded{Version=[2],Text=[When the setting of the base priority of a ready |
| 1597 |
task takes effect and the new priority is in a range specified as |
| 1598 |
EDF_Across_Priorities, the task is added to the ready queue |
| 1599 |
corresponding to its new active priority, as determined above.]} |
| 1600 |
|
| 1601 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1602 |
@ChgAdded{Version=[2],Text=[For all the operations defined in Dispatching.EDF, |
| 1603 |
Tasking_Error is raised if the task identified by T has terminated. |
| 1604 |
Program_Error is raised if the value of T is Null_Task_Id.]} |
| 1605 |
|
| 1606 |
@end{RunTime} |
| 1607 |
|
| 1608 |
@begin{Bounded} |
| 1609 |
|
| 1610 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1611 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 1612 |
If EDF_Across_Priorities is specified for priority range @i<Low>..@i<High>, it |
| 1613 |
is a bounded error to declare a protected object with ceiling priority |
| 1614 |
@i<Low> or to assign the value @i<Low> to attribute 'Priority. In either case |
| 1615 |
either Program_Error is raised or the ceiling of the protected |
| 1616 |
object is assigned the value @i<Low>+1.]} |
| 1617 |
|
| 1618 |
@end{Bounded} |
| 1619 |
|
| 1620 |
@begin{Erron} |
| 1621 |
|
| 1622 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1623 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 1624 |
If a value of Task_Id is passed as a parameter to any of the subprograms |
| 1625 |
of this package and the corresponding task object no longer exists, |
| 1626 |
the execution of the program is erroneous.]} |
| 1627 |
|
| 1628 |
@end{Erron} |
| 1629 |
|
| 1630 |
@begin{DocReq} |
| 1631 |
|
| 1632 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1633 |
@ChgAdded{Version=[2],Text=[On a multiprocessor, the implementation shall |
| 1634 |
document any conditions that cause the completion of the setting of the deadline |
| 1635 |
of a task to be delayed later than what is specified for a single processor.]} |
| 1636 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 1637 |
Text=[Any conditions that cause the completion of the setting of the deadline |
| 1638 |
of a task to be delayed for a multiprocessor.]}]} |
| 1639 |
@end{DocReq} |
| 1640 |
|
| 1641 |
@begin{Notes} |
| 1642 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1643 |
@ChgAdded{Version=[2],Text=[If two adjacent priority ranges, @i<A>..@i<B> and |
| 1644 |
@i<B>+1..@i<C> are specified to have policy |
| 1645 |
EDF_Across_Priorities then this is not equivalent to this policy being |
| 1646 |
specified for the single range, @i<A>..@i<C>.]} |
| 1647 |
|
| 1648 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1649 |
@ChgAdded{Version=[2],Text=[The above rules implement the preemption-level |
| 1650 |
protocol (also called Stack Resource Policy protocol) for resource sharing |
| 1651 |
under EDF dispatching. The preemption-level for a task is denoted by its base |
| 1652 |
priority. The definition of a ceiling preemption-level for a protected object |
| 1653 |
follows the existing rules for ceiling locking.]} |
| 1654 |
|
| 1655 |
@begin{ImplNote} |
| 1656 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1657 |
@ChgAdded{Version=[2],Text=[An implementation may support additional |
| 1658 |
dispatching policies by replacing absolute deadline with an alternative |
| 1659 |
measure of urgency.]} |
| 1660 |
@end{ImplNote} |
| 1661 |
|
| 1662 |
@end{Notes} |
| 1663 |
|
| 1664 |
@begin{Extend95} |
| 1665 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 1666 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 1667 |
Policy EDF_Across_Priorities and package Dispatching.EDF are new.]} |
| 1668 |
@end{Extend95} |
| 1669 |
|
| 1670 |
|
| 1671 |
@LabeledClause{Priority Ceiling Locking} |
| 1672 |
|
| 1673 |
@begin{Intro} |
| 1674 |
@Redundant[This clause specifies the interactions between priority task |
| 1675 |
scheduling and protected object ceilings. This interaction is based on |
| 1676 |
the concept of the @i{ceiling priority} of a protected object.] |
| 1677 |
@end{Intro} |
| 1678 |
|
| 1679 |
@begin{Syntax} |
| 1680 |
@begin{SyntaxText} |
| 1681 |
@Leading@Keepnext@;The form of a @nt{pragma} Locking_Policy is as follows: |
| 1682 |
@end{SyntaxText} |
| 1683 |
|
| 1684 |
@PragmaSyn`@key{pragma} @prag(Locking_Policy)(@SynI{policy_}@Syn2{identifier});' |
| 1685 |
@end{Syntax} |
| 1686 |
|
| 1687 |
@begin{Legality} |
| 1688 |
|
| 1689 |
The @SynI{policy_}@Syn2{identifier} shall either be Ceiling_Locking |
| 1690 |
or an implementation-defined @Syn2{identifier}. |
| 1691 |
@ImplDef{Implementation-defined @SynI{policy_}@Syn2{identifier}s allowed |
| 1692 |
in a @nt{pragma} Locking_Policy.} |
| 1693 |
|
| 1694 |
@end{Legality} |
| 1695 |
|
| 1696 |
@begin{LinkTime} |
| 1697 |
|
| 1698 |
@PDefn2{Term=[configuration pragma], Sec=(Locking_Policy)} |
| 1699 |
@PDefn2{Term=[pragma, configuration], Sec=(Locking_Policy)} |
| 1700 |
A Locking_Policy pragma is a configuration pragma. |
| 1701 |
|
| 1702 |
@end{LinkTime} |
| 1703 |
|
| 1704 |
@begin{RunTime} |
| 1705 |
|
| 1706 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0073],ARef=[AI95-00091-01]} |
| 1707 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 1708 |
@Defn{locking policy} |
| 1709 |
@Redundant[A locking policy specifies the details of protected object |
| 1710 |
locking. @Chg{Version=[2],New=[All protected objects have a priority. |
| 1711 |
The locking policy specifies the meaning of |
| 1712 |
the priority of a],Old=[These rules specify whether or not]} protected @Chg{Version=[2], |
| 1713 |
New=[object],Old=[objects have |
| 1714 |
priorities]}, and the relationships between these priorities and |
| 1715 |
task priorities. In addition, the policy specifies the state of a task |
| 1716 |
when it executes a protected action, and how its active priority is |
| 1717 |
affected by the locking.] |
| 1718 |
The @i{locking policy} is specified by a Locking_Policy pragma. For |
| 1719 |
implementation-defined locking policies, the @Chg{Version=[2],New=[meaning of |
| 1720 |
the priority of],Old=[effect of a Priority or |
| 1721 |
Interrupt_Priority pragma on]} a protected object is |
| 1722 |
implementation defined. |
| 1723 |
If no Locking_Policy pragma @Chg{New=[applies to],Old=[appears in]} any |
| 1724 |
of the program units comprising a partition, the locking policy for that |
| 1725 |
partition, as well as the @Chg{Version=[2],New=[meaning of |
| 1726 |
the priority of],Old=[effect of specifying either a Priority or |
| 1727 |
Interrupt_Priority pragma for]} a protected object, are implementation defined. |
| 1728 |
@Chg{Version=[2],New=[@Defn2{Term=[Priority],Sec=[of a protected object]}],Old=[]} |
| 1729 |
|
| 1730 |
@ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 1731 |
Text=[The locking policy if no Locking_Policy pragma applies to any unit of |
| 1732 |
a partition.]}]} |
| 1733 |
|
| 1734 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00327-01]} |
| 1735 |
@ChgAdded{Version=[2],Text=[The @nt{expression} of a Priority or Interrupt_Priority |
| 1736 |
pragma (see @RefSecNum{Task Priorities}) is evaluated as part of the creation |
| 1737 |
of the corresponding |
| 1738 |
protected object and converted to the subtype System.Any_Priority or |
| 1739 |
System.Interrupt_Priority, respectively. The value of the expression is the |
| 1740 |
initial priority of the corresponding protected object. If no Priority or |
| 1741 |
Interrupt_Priority pragma applies to a protected object, the initial priority |
| 1742 |
is specified by the locking policy. |
| 1743 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)} |
| 1744 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)}]} |
| 1745 |
|
| 1746 |
@Leading@;There is one predefined locking policy, Ceiling_Locking; this policy is |
| 1747 |
defined as follows: |
| 1748 |
@begin{itemize} |
| 1749 |
|
| 1750 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 1751 |
@Defn2{Term=[ceiling priority], Sec=(of a protected object)} |
| 1752 |
Every protected object has a @i{ceiling priority}, which |
| 1753 |
is determined by either a Priority or Interrupt_Priority pragma as |
| 1754 |
defined in @RefSecNum{Task Priorities}@Chg{Version=[2],New=[, or by |
| 1755 |
assignment to the Priority attribute as described |
| 1756 |
in @RefSecNum{Dynamic Priorities for Protected Objects}],Old=[]}. |
| 1757 |
The ceiling priority of a protected object (or ceiling, for short) is an |
| 1758 |
upper bound on the active priority a task can have when |
| 1759 |
it calls protected operations of that protected object. |
| 1760 |
|
| 1761 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 1762 |
The @Chg{Version=[2],New=[initial ceiling priority of a],Old=[@nt{expression} |
| 1763 |
of a Priority or Interrupt_Priority pragma is evaluated |
| 1764 |
as part of the creation of the corresponding]} |
| 1765 |
protected object |
| 1766 |
@Chg{Version=[2],New=[is |
| 1767 |
equal to the initial priority for that object.],Old=[and converted |
| 1768 |
to the subtype System.Any_Priority or System.Interrupt_Priority, respectively. |
| 1769 |
The value of the @nt{expression} is the ceiling priority of |
| 1770 |
the corresponding protected object. |
| 1771 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)} |
| 1772 |
@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)}]} |
| 1773 |
|
| 1774 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 1775 |
If an Interrupt_Handler or Attach_Handler pragma |
| 1776 |
(see @RefSecNum{Protected Procedure Handlers}) appears in a |
| 1777 |
@nt{protected_definition} without an Interrupt_Priority pragma, the |
| 1778 |
@Chg{Version=[2],New=[initial],Old=[ceiling]} priority of protected objects |
| 1779 |
of that type is implementation defined, |
| 1780 |
but in the range of the subtype System.Interrupt_Priority. |
| 1781 |
@ImplDef{Default ceiling priorities.} |
| 1782 |
|
| 1783 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 1784 |
If no @nt{pragma} Priority, Interrupt_Priority, |
| 1785 |
Interrupt_Handler, or Attach_Handler is specified in the |
| 1786 |
@nt{protected_definition}, then the @Chg{Version=[2],New=[initial],Old=[ceiling]} |
| 1787 |
priority of the corresponding protected object is System.Priority'Last. |
| 1788 |
|
| 1789 |
While a task executes a protected action, it inherits the ceiling |
| 1790 |
priority of the corresponding protected object. |
| 1791 |
|
| 1792 |
@IndexCheck{Ceiling_Check} |
| 1793 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)} |
| 1794 |
When a task calls a protected operation, a check is made that its active |
| 1795 |
priority is not higher than the ceiling of the corresponding protected object; |
| 1796 |
Program_Error is raised if this check fails. |
| 1797 |
|
| 1798 |
@end{Itemize} |
| 1799 |
|
| 1800 |
@end{RunTime} |
| 1801 |
|
| 1802 |
@begin{Bounded} |
| 1803 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00327-01]} |
| 1804 |
@ChgAdded{Version=[2],Type=[Leading],Text=[Following any change of priority, |
| 1805 |
it is a bounded error for the active priority of any task with a call queued on |
| 1806 |
an entry of a protected object to be higher than the ceiling priority of the |
| 1807 |
protected object. |
| 1808 |
@PDefn2{Term=(bounded error),Sec=(cause)} |
| 1809 |
In this case one of the following applies:]} |
| 1810 |
|
| 1811 |
@begin{Itemize} |
| 1812 |
|
| 1813 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1814 |
@ChgAdded{Version=[2],Text=[at any time prior to executing the entry body |
| 1815 |
Program_Error is raised in the calling task; |
| 1816 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]} |
| 1817 |
|
| 1818 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1819 |
@ChgAdded{Version=[2],Text=[when the entry is open the entry body is executed |
| 1820 |
at the ceiling priority of the protected object;]} |
| 1821 |
|
| 1822 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1823 |
@ChgAdded{Version=[2],Text=[when the entry is open the entry body is executed |
| 1824 |
at the ceiling priority of the protected object and then Program_Error is |
| 1825 |
raised in the calling task; or |
| 1826 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]} |
| 1827 |
|
| 1828 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1829 |
@ChgAdded{Version=[2],Text=[when the entry is open the entry body |
| 1830 |
is executed at the ceiling priority of the protected object that was in effect |
| 1831 |
when the entry call was queued.]} |
| 1832 |
@end{Itemize} |
| 1833 |
@begin{Ramification} |
| 1834 |
@ChgRef{Version=[2],Kind=[Added]}@Comment{This note was moved along with the above rules} |
| 1835 |
@ChgAdded{Version=[2],Text=[Note that the error is @lquotes@;blamed@rquotes@; |
| 1836 |
on the task that did the entry call, not the task that changed the |
| 1837 |
priority of the task or protected object. |
| 1838 |
This seems to make sense for the case of changing the priority of a task |
| 1839 |
blocked on a call, since if the Set_Priority had happened a |
| 1840 |
little bit sooner, before the task queued a call, |
| 1841 |
the entry-calling task would get the error. |
| 1842 |
Similarly, there is no reason not to raise the priority of a |
| 1843 |
task that is executing in an @nt{abortable_part}, so long as its |
| 1844 |
priority is lowered before it gets to the end and needs to cancel the |
| 1845 |
call. |
| 1846 |
The priority might need to be lowered to allow it to remove the call |
| 1847 |
from the entry queue, |
| 1848 |
in order to avoid violating the ceiling. |
| 1849 |
This seems relatively harmless, since there is an error, |
| 1850 |
and the task is about to start raising an exception anyway.]} |
| 1851 |
@end{Ramification} |
| 1852 |
@end{Bounded} |
| 1853 |
|
| 1854 |
@begin{ImplPerm} |
| 1855 |
|
| 1856 |
The implementation is allowed to round all ceilings in a certain |
| 1857 |
subrange of System.Priority or System.Interrupt_Priority up to |
| 1858 |
the top of that subrange, uniformly. |
| 1859 |
@begin{Discussion} |
| 1860 |
For example, an implementation might use Priority'Last for all ceilings |
| 1861 |
in Priority, and Interrupt_Priority'Last for all ceilings in |
| 1862 |
Interrupt_Priority. |
| 1863 |
This would be equivalent to having two ceiling priorities for protected objects, |
| 1864 |
@lquotes@;nonpreemptible@rquotes@; and @lquotes@;noninterruptible@rquotes@;, and is an allowed behavior. |
| 1865 |
|
| 1866 |
Note that the implementation cannot choose a subrange that crosses the |
| 1867 |
boundary between normal and interrupt priorities. |
| 1868 |
@end{Discussion} |
| 1869 |
|
| 1870 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]} |
| 1871 |
Implementations are allowed to define other locking policies, |
| 1872 |
but need not support more than one @Chg{Version=[2],New=[locking],Old=[such]} |
| 1873 |
policy per partition. |
| 1874 |
|
| 1875 |
@Redundant[Since implementations are allowed to place restrictions |
| 1876 |
on code that runs at an interrupt-level active priority |
| 1877 |
(see @RefSecNum{Protected Procedure Handlers} |
| 1878 |
and @RefSecNum{The Task Dispatching Model}), |
| 1879 |
the implementation may implement a language feature in terms |
| 1880 |
of a protected object with an implementation-defined ceiling, |
| 1881 |
but the ceiling shall be no less than Priority'Last.] |
| 1882 |
@ImplDef{The ceiling of any protected object used internally by the |
| 1883 |
implementation.} |
| 1884 |
@begin{TheProof} |
| 1885 |
This permission follows from the fact that |
| 1886 |
the implementation can place restrictions on interrupt |
| 1887 |
handlers and on any other code that runs at an interrupt-level |
| 1888 |
active priority. |
| 1889 |
|
| 1890 |
The implementation might protect a storage pool with a |
| 1891 |
protected object whose ceiling is Priority'Last, which would cause |
| 1892 |
@nt{allocator}s to fail when evaluated at interrupt priority. |
| 1893 |
Note that the ceiling of such an object has to be at least |
| 1894 |
Priority'Last, |
| 1895 |
since there is no permission for @nt{allocator}s to fail when evaluated at |
| 1896 |
a non-interrupt priority. |
| 1897 |
@end{TheProof} |
| 1898 |
|
| 1899 |
@end{ImplPerm} |
| 1900 |
|
| 1901 |
@begin{ImplAdvice} |
| 1902 |
|
| 1903 |
The implementation should use names that end with |
| 1904 |
@lquotes@;_Locking@rquotes@; for implementation-defined locking policies. |
| 1905 |
|
| 1906 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 1907 |
Text=[Names that end with @lquotes@;_Locking@rquotes@; should be used for |
| 1908 |
implementation-defined locking policies.]}]} |
| 1909 |
|
| 1910 |
@end{ImplAdvice} |
| 1911 |
|
| 1912 |
@begin{Notes} |
| 1913 |
|
| 1914 |
While a task executes in a protected action, it can be preempted |
| 1915 |
only by tasks whose active priorities are higher than the |
| 1916 |
ceiling priority of the protected object. |
| 1917 |
|
| 1918 |
If a protected object has a ceiling priority in the range |
| 1919 |
of Interrupt_Priority, certain interrupts are blocked while |
| 1920 |
protected actions of that object execute. In the extreme, if |
| 1921 |
the ceiling is Interrupt_Priority'Last, all blockable interrupts |
| 1922 |
are blocked during that time. |
| 1923 |
|
| 1924 |
The ceiling priority of a protected object has to be in the |
| 1925 |
Interrupt_Priority range if one of its procedures is to be used as |
| 1926 |
an interrupt handler (see @RefSecNum{Interrupt Support}). |
| 1927 |
|
| 1928 |
When specifying the ceiling of a protected object, one should |
| 1929 |
choose a value that is at least as high as the highest active priority |
| 1930 |
at which tasks can be executing when they call |
| 1931 |
protected operations of that object. In determining this |
| 1932 |
value the following factors, which can affect active priority, |
| 1933 |
should be considered: the effect of Set_Priority, nested |
| 1934 |
protected operations, entry calls, task activation, and other |
| 1935 |
implementation-defined factors. |
| 1936 |
|
| 1937 |
Attaching a protected procedure whose ceiling is below the |
| 1938 |
interrupt hardware priority to an interrupt causes the execution of the |
| 1939 |
program to be erroneous |
| 1940 |
(see @RefSecNum{Protected Procedure Handlers}). |
| 1941 |
|
| 1942 |
On a single processor implementation, the ceiling priority |
| 1943 |
rules guarantee that there is no possibility of deadlock involving |
| 1944 |
only protected subprograms (excluding the case where a protected operation |
| 1945 |
calls another protected operation on the same protected object). |
| 1946 |
|
| 1947 |
@end{Notes} |
| 1948 |
|
| 1949 |
@begin{Extend95} |
| 1950 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 1951 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 1952 |
All protected objects now have a priority, which |
| 1953 |
is the value of the Priority attribute of |
| 1954 |
@RefSecNum{Dynamic Priorities for Protected Objects}. How this value |
| 1955 |
is interpreted depends on the locking policy; for instance, the ceiling |
| 1956 |
priority is derived from this value when the locking policy is |
| 1957 |
Ceiling_Locking.]} |
| 1958 |
@end{Extend95} |
| 1959 |
|
| 1960 |
@begin{DiffWord95} |
| 1961 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0073],ARef=[AI95-00091-01]} |
| 1962 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the wording to |
| 1963 |
reflect that pragma Locking_Policy cannot be inside of a program unit.]} |
| 1964 |
|
| 1965 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]} |
| 1966 |
@ChgAdded{Version=[2],Text=[Clarified that an implementation need support |
| 1967 |
only one locking policy (of any kind, language-defined or otherwise) |
| 1968 |
per partition.]} |
| 1969 |
|
| 1970 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 1971 |
@ChgAdded{Version=[2],Text=[The bounded error for the priority of a task |
| 1972 |
being higher than the ceiling of an object it is currently in was moved here |
| 1973 |
from @RefSecNum{Dynamic Priorities}, so that it applies no matter how the |
| 1974 |
situation arises.]} |
| 1975 |
@end{DiffWord95} |
| 1976 |
|
| 1977 |
|
| 1978 |
@Comment{@RMNewPage Break here so printed Ada 95 RM looks better.} |
| 1979 |
@LabeledClause{Entry Queuing Policies} |
| 1980 |
|
| 1981 |
@begin{Intro} |
| 1982 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0074],ARef=[AI95-00068-01]} |
| 1983 |
@Redundant[@Defn{queuing policy} |
| 1984 |
This clause specifies a mechanism for a user to choose an entry |
| 1985 |
@i{queuing policy}. It also defines @Chg{New=[two],Old=[one]} |
| 1986 |
such polic@Chg{New=[ies],Old=[y]}. Other policies are implementation defined.] |
| 1987 |
@ImplDef{Implementation-defined queuing policies.} |
| 1988 |
@end{Intro} |
| 1989 |
|
| 1990 |
@begin{Syntax} |
| 1991 |
@begin{SyntaxText} |
| 1992 |
@Leading@Keepnext@;The form of a @nt{pragma} Queuing_Policy is as follows: |
| 1993 |
@end{SyntaxText} |
| 1994 |
|
| 1995 |
@PragmaSyn`@key{pragma} @prag(Queuing_Policy)(@SynI{policy_}@Syn2{identifier});' |
| 1996 |
@end{Syntax} |
| 1997 |
|
| 1998 |
@begin{Legality} |
| 1999 |
|
| 2000 |
The @SynI{policy_}@Syn2{identifier} shall be either FIFO_Queuing, |
| 2001 |
Priority_Queuing or an implementation-defined @Syn2{identifier}. |
| 2002 |
|
| 2003 |
@end{Legality} |
| 2004 |
|
| 2005 |
@begin{LinkTime} |
| 2006 |
|
| 2007 |
@PDefn2{Term=[configuration pragma], Sec=(Queuing_Policy)} |
| 2008 |
@PDefn2{Term=[pragma, configuration], Sec=(Queuing_Policy)} |
| 2009 |
A Queuing_Policy pragma is a configuration pragma. |
| 2010 |
|
| 2011 |
@end{LinkTime} |
| 2012 |
|
| 2013 |
@begin{RunTime} |
| 2014 |
|
| 2015 |
@Defn{queuing policy} |
| 2016 |
@Redundant[A @i{queuing policy} governs the order in which tasks are queued |
| 2017 |
for entry service, and the order in which different entry queues are |
| 2018 |
considered for service.] |
| 2019 |
The queuing policy is specified by a Queuing_Policy pragma. |
| 2020 |
@begin{Ramification} |
| 2021 |
The queuing policy includes entry queuing order, |
| 2022 |
the choice among open alternatives of a @nt{selective_accept}, |
| 2023 |
and the choice among queued entry calls of |
| 2024 |
a protected object when more than one @nt{entry_barrier} @nt{condition} is True. |
| 2025 |
@end{Ramification} |
| 2026 |
|
| 2027 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]} |
| 2028 |
Two queuing policies, FIFO_Queuing and Priority_Queuing, |
| 2029 |
are language defined. If no Queuing_Policy pragma |
| 2030 |
@Chg{Version=[2],New=[applies to],Old=[appears in]} any of the program units |
| 2031 |
comprising the partition, the queuing policy for that partition |
| 2032 |
is FIFO_Queuing. The rules for this policy are specified in |
| 2033 |
@RefSecNum{Entry Calls} and @RefSecNum{Selective Accept}. |
| 2034 |
|
| 2035 |
@Leading@Keepnext@;The Priority_Queuing policy is defined as follows: |
| 2036 |
@begin{itemize} |
| 2037 |
|
| 2038 |
@Defn{priority of an entry call} |
| 2039 |
The calls to an entry @Redundant[(including a member of an entry family)] |
| 2040 |
are queued in an order consistent with the priorities of the calls. The |
| 2041 |
@i{priority of an entry call} is initialized from the active |
| 2042 |
priority of the calling task at the time |
| 2043 |
the call is made, but can change later. Within the same priority, |
| 2044 |
the order is consistent with the calling (or requeuing, |
| 2045 |
or priority setting) time (that is, a FIFO order). |
| 2046 |
|
| 2047 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0075],ARef=[AI95-00205-01]} |
| 2048 |
After a call is first queued, changes to the active priority of a task do |
| 2049 |
not affect the priority of the call, unless the base priority of the task is |
| 2050 |
set@Chg{New=[ while the task is blocked on an entry call],Old=[]}. |
| 2051 |
|
| 2052 |
When the base priority of a task is set (see @RefSecNum{Dynamic Priorities}), |
| 2053 |
if the task is blocked on an entry call, and the call is queued, |
| 2054 |
the priority of the call is updated to the new active priority of the |
| 2055 |
calling task. This causes the call to be removed from and then reinserted in |
| 2056 |
the queue at the new active priority. |
| 2057 |
@begin{Reason} |
| 2058 |
A task is blocked on an entry call if the entry call is simple, |
| 2059 |
conditional, or timed. |
| 2060 |
If the call came from the @nt{triggering_statement} of an |
| 2061 |
@nt{asynchronous_select}, or a requeue thereof, |
| 2062 |
then the task is not blocked on that call; |
| 2063 |
such calls do not have their priority updated. |
| 2064 |
Thus, there can exist many queued calls from a given task |
| 2065 |
(caused by many nested ATC's), |
| 2066 |
but a task can be blocked on only one call at a time. |
| 2067 |
|
| 2068 |
A previous version of Ada 9X required queue reordering in the |
| 2069 |
@nt{asynchronous_select} case as well. |
| 2070 |
If the call corresponds to a @lquotes@;synchronous@rquotes@; entry call, then the task |
| 2071 |
is blocked while queued, and it makes good sense to move it up in the |
| 2072 |
queue if its priority is raised. |
| 2073 |
|
| 2074 |
However, if the entry call is @lquotes@;asynchronous,@rquotes@; that is, it is |
| 2075 |
due to an @nt{asynchronous_select} whose @nt{triggering_statement} |
| 2076 |
is an entry call, then the task is not waiting for this |
| 2077 |
entry call, so the placement of the entry call on the |
| 2078 |
queue is irrelevant to the rate at which the task proceeds. |
| 2079 |
|
| 2080 |
Furthermore, when an entry is used for @nt{asynchronous_select}s, |
| 2081 |
it is almost certain to be a @lquotes@;broadcast@rquotes@; entry or have |
| 2082 |
only one caller at a time. For example, if the entry is |
| 2083 |
used to notify tasks of a mode switch, then all tasks on the |
| 2084 |
entry queue would be signaled when the mode changes. Similarly, |
| 2085 |
if it is indicating some interrupting event such as a control-C, |
| 2086 |
all tasks sensitive to the interrupt will want to be informed |
| 2087 |
that the event occurred. Hence, the order on such a queue is |
| 2088 |
essentially irrelevant. |
| 2089 |
|
| 2090 |
Given the above, it seems an unnecessary semantic and implementation |
| 2091 |
complexity to specify that asynchronous queued calls are moved in |
| 2092 |
response to dynamic priority changes. Furthermore, it is somewhat |
| 2093 |
inconsistent, since the call was originally queued based on the active |
| 2094 |
priority of the task, but dynamic priority changes are changing the base |
| 2095 |
priority of the task, and only indirectly the active priority. We say |
| 2096 |
explicitly that asynchronous queued calls are not affected by normal |
| 2097 |
changes in active priority during the execution of an |
| 2098 |
@nt{abortable_part}. Saying that, if a change in the base priority |
| 2099 |
affects the active priority, then we do want the calls reordered, would |
| 2100 |
be inconsistent. |
| 2101 |
It would also require the implementation to maintain a readily |
| 2102 |
accessible list of all queued calls which would not otherwise be |
| 2103 |
necessary. |
| 2104 |
|
| 2105 |
Several rules were removed or simplified when we changed the rules so |
| 2106 |
that calls due to @nt{asynchronous_select}s are never moved due to |
| 2107 |
intervening changes in active priority, be they due to protected |
| 2108 |
actions, some other priority inheritance, or changes in the base |
| 2109 |
priority. |
| 2110 |
@end{Reason} |
| 2111 |
|
| 2112 |
When more than one @nt{condition} of an @nt{entry_barrier} of a protected |
| 2113 |
object becomes True, and more than one of the respective queues is nonempty, |
| 2114 |
the call with the highest priority is selected. If more than one such |
| 2115 |
call has the same priority, the call that is queued on the entry whose |
| 2116 |
declaration is first in textual order in the @nt{protected_definition} is |
| 2117 |
selected. For members of the same entry family, |
| 2118 |
the one with the lower family index is selected. |
| 2119 |
|
| 2120 |
If the expiration time of two or more open |
| 2121 |
@nt{delay_alternative}s is the same and no other |
| 2122 |
@nt{accept_alternative}s are open, the |
| 2123 |
@nt{sequence_of_statements} of the @nt{delay_alternative} that is |
| 2124 |
first in textual order in the @nt{selective_accept} is executed. |
| 2125 |
|
| 2126 |
When more than one alternative of a @nt{selective_accept} is |
| 2127 |
open and has queued calls, an alternative whose queue has the highest-priority |
| 2128 |
call at its head is selected. |
| 2129 |
If two or more open alternatives have equal-priority queued calls, |
| 2130 |
then a call on the entry in the @nt{accept_alternative} that is |
| 2131 |
first in textual order in the @nt{selective_accept} |
| 2132 |
is selected. |
| 2133 |
|
| 2134 |
@end{itemize} |
| 2135 |
|
| 2136 |
@end{RunTime} |
| 2137 |
|
| 2138 |
@begin{ImplPerm} |
| 2139 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]} |
| 2140 |
Implementations are allowed to define other queuing policies, but |
| 2141 |
need not support more than one @Chg{Version=[2],New=[queuing],Old=[such]} |
| 2142 |
policy per partition. |
| 2143 |
@begin{Discussion} |
| 2144 |
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0116],ARef=[AI95-00069-01]} |
| 2145 |
@ChgRef{Version=[2],Kind=[RevisedAdded],ARef=[AI95-00256-01]} |
| 2146 |
@ChgAdded{Version=[1],Text=[This rule is really redundant, as |
| 2147 |
@RefSecNum(Pragmas and Program Units) allows an implementation to limit the |
| 2148 |
use of configuration pragmas to an empty environment. In that case, there |
| 2149 |
would be no way to have multiple policies in a partition.@Chg{Version=[2],New=[], |
| 2150 |
Old=[ In any case, the |
| 2151 |
wording here really ought to be "...more than one queuing policy per |
| 2152 |
partition.", since this part of the rule applies to all queuing policies, not |
| 2153 |
just implementation-defined ones.]}]} |
| 2154 |
@end{Discussion} |
| 2155 |
|
| 2156 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00188-02]} |
| 2157 |
@ChgAdded{Version=[2],Text=[Implementations are allowed to defer the reordering |
| 2158 |
of entry queues following a change of base priority of a task blocked on the |
| 2159 |
entry call if it is not practical to reorder the queue immediately.]} |
| 2160 |
@begin{Reason} |
| 2161 |
@ChgRef{Version=[2],Kind=[Added]} |
| 2162 |
@ChgAdded{Version=[2],Text=[Priority change is immediate, but the effect of the |
| 2163 |
change on entry queues can be deferred. That is necessary in order to implement |
| 2164 |
priority changes on top of a non-Ada kernel.]} |
| 2165 |
@end{Reason} |
| 2166 |
@begin{Discussion} |
| 2167 |
@ChgRef{Version=[2],Kind=[Added]} |
| 2168 |
@ChgAdded{Version=[2],Text=[The reordering should occur as soon as the blocked |
| 2169 |
task can itself perform the reinsertion into the entry queue.]} |
| 2170 |
@end{Discussion} |
| 2171 |
@end{ImplPerm} |
| 2172 |
|
| 2173 |
@begin{ImplAdvice} |
| 2174 |
|
| 2175 |
The implementation should use names that end with |
| 2176 |
@lquotes@;_Queuing@rquotes@; for implementation-defined queuing policies. |
| 2177 |
|
| 2178 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2179 |
Text=[Names that end with @lquotes@;_Queuing@rquotes@; should be used for |
| 2180 |
implementation-defined queuing policies.]}]} |
| 2181 |
|
| 2182 |
@end{ImplAdvice} |
| 2183 |
|
| 2184 |
@begin{DiffWord95} |
| 2185 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0074],ARef=[AI95-00068-01]} |
| 2186 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the number of |
| 2187 |
queuing policies defined.]} |
| 2188 |
|
| 2189 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0075],ARef=[AI95-00205-01]} |
| 2190 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected so that a call of |
| 2191 |
Set_Priority in an abortable part does not change the priority of the |
| 2192 |
triggering entry call.]} |
| 2193 |
|
| 2194 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00188-02]} |
| 2195 |
@ChgAdded{Version=[2],Text=[Added a permission to defer queue reordering |
| 2196 |
when the base priority of a task is changed. This is a counterpart to |
| 2197 |
stronger requirements on the implementation of priority change.]} |
| 2198 |
|
| 2199 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]} |
| 2200 |
@ChgAdded{Version=[2],Text=[Clarified that an implementation need support |
| 2201 |
only one queuing policy (of any kind, language-defined or otherwise) |
| 2202 |
per partition.]} |
| 2203 |
|
| 2204 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 2205 |
@ChgAdded{Version=[2],Text=[Fixed wording to make clear that @nt{pragma} |
| 2206 |
never appears inside of a unit; rather it @lquotes@;applies to@rquotes the |
| 2207 |
unit.]} |
| 2208 |
@end{DiffWord95} |
| 2209 |
|
| 2210 |
|
| 2211 |
@LabeledClause{Dynamic Priorities} |
| 2212 |
|
| 2213 |
|
| 2214 |
@begin{Intro} |
| 2215 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2216 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause describes how the |
| 2217 |
priority of an entity can be modified or queried at run time.]]} |
| 2218 |
@end{Intro} |
| 2219 |
|
| 2220 |
@begin{DiffWord95} |
| 2221 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2222 |
@ChgAdded{Version=[2],Text=[This clause is turned into two subclauses. |
| 2223 |
This clause introduction is new.]} |
| 2224 |
@end{DiffWord95} |
| 2225 |
|
| 2226 |
|
| 2227 |
@LabeledAddedSubClause{Version=[2],Name=[Dynamic Priorities for Tasks]} |
| 2228 |
|
| 2229 |
@begin{Intro} |
| 2230 |
@Redundant[This clause describes how the base priority of a task can be |
| 2231 |
modified or queried at run time.] |
| 2232 |
@end{Intro} |
| 2233 |
|
| 2234 |
@begin{StaticSem} |
| 2235 |
@Leading@Keepnext@;The following language-defined library package exists: |
| 2236 |
@begin{Example} |
| 2237 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]} |
| 2238 |
@key[with] System; |
| 2239 |
@key[with] Ada.Task_Identification; @RI{-- See @RefSecNum[The Package Task_Identification]} |
| 2240 |
@key[package] Ada.Dynamic_Priorities @key[is]@ChildUnit{Parent=[Ada],Child=[Dynamic_Priorities]}@Chg{Version=[2],New=[ |
| 2241 |
@key[pragma] Preelaborate(Dynamic_Priorities);],Old=[]} |
| 2242 |
|
| 2243 |
@key[procedure] @AdaSubDefn{Set_Priority}(Priority : @key[in] System.Any_Priority; |
| 2244 |
T : @key[in] Ada.Task_Identification.Task_Id := |
| 2245 |
Ada.Task_Identification.Current_Task); |
| 2246 |
|
| 2247 |
@key[function] @AdaSubDefn{Get_Priority} (T : Ada.Task_Identification.Task_Id := |
| 2248 |
Ada.Task_Identification.Current_Task) |
| 2249 |
@key[return] System.Any_Priority; |
| 2250 |
|
| 2251 |
@key[end] Ada.Dynamic_Priorities; |
| 2252 |
@end{example} |
| 2253 |
@end{StaticSem} |
| 2254 |
|
| 2255 |
@begin{RunTime} |
| 2256 |
The procedure Set_Priority sets the base priority of the specified task |
| 2257 |
to the specified Priority value. |
| 2258 |
Set_Priority has no effect if the task is terminated. |
| 2259 |
|
| 2260 |
The function Get_Priority returns T's current base priority. |
| 2261 |
@Defn2{Term=[Tasking_Error],Sec=(raised by failure of run-time check)} |
| 2262 |
Tasking_Error is raised if the task is terminated. |
| 2263 |
@begin{Reason} |
| 2264 |
There is no harm in setting the priority of a terminated task. |
| 2265 |
A previous version of Ada 9X made this a run-time error. |
| 2266 |
However, there is little difference between setting the priority of a |
| 2267 |
terminated task, and setting the priority of a task that is about to |
| 2268 |
terminate very soon; |
| 2269 |
neither case should be an error. |
| 2270 |
Furthermore, the run-time check is not necessarily feasible to implement |
| 2271 |
on all systems, since priority changes might be deferred due to |
| 2272 |
inter-processor communication overhead, |
| 2273 |
so the error might not be detected until after Set_Priority has |
| 2274 |
returned. |
| 2275 |
|
| 2276 |
However, we wish to allow implementations to avoid storing @lquotes@;extra@rquotes@; |
| 2277 |
information about terminated tasks. |
| 2278 |
Therefore, we make Get_Priority of a terminated task raise an exception; |
| 2279 |
the implementation need not continue to store the priority of a task |
| 2280 |
that has terminated. |
| 2281 |
@end{Reason} |
| 2282 |
|
| 2283 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)} |
| 2284 |
Program_Error is raised by Set_Priority and Get_Priority if T is equal |
| 2285 |
to Null_Task_Id. |
| 2286 |
|
| 2287 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00188-02]} |
| 2288 |
@Chg{Version=[2],New=[On a system with a single processor, the setting of], |
| 2289 |
Old=[Setting]} the @Chg{Version=[2],New=[],Old=[task's ]}base |
| 2290 |
priority@Chg{Version=[2],New=[ of a task @i{T}],Old=[]} |
| 2291 |
to the new value @Chg{Version=[2], |
| 2292 |
New=[occurs immediately at the first point when @i{T} is |
| 2293 |
outside the execution of],Old=[takes place as soon |
| 2294 |
as is practical but not while the task is performing]} a |
| 2295 |
protected action@Chg{Version=[2],New=[],Old=[. |
| 2296 |
This setting occurs no later then the next abort completion point of |
| 2297 |
the task T |
| 2298 |
(see @RefSecNum{Abort of a Task - Abort of a Sequence of Statements})]}. |
| 2299 |
|
| 2300 |
@begin{ImplNote} |
| 2301 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00188-02]} |
| 2302 |
@Chg{Version=[2],New=[The priority change is immediate if the target task |
| 2303 |
is on a delay queue or a ready queue outside of a protected action. |
| 2304 |
However, consider when],Old=[When]} |
| 2305 |
Set_Priority is called by a task T1 to set the priority of T2, |
| 2306 |
if T2 is blocked, waiting on an entry call queued on a protected object, |
| 2307 |
the entry queue needs to be reordered. |
| 2308 |
Since T1 might have a priority that is higher than the ceiling of the |
| 2309 |
protected object, T1 cannot, in general, do the reordering. |
| 2310 |
One way to implement this is to wake T2 up and have T2 do the work. |
| 2311 |
This is similar to the disentangling of queues that needs to happen when |
| 2312 |
a high-priority task aborts a lower-priority task, |
| 2313 |
which might have a call queued on a protected object with a low |
| 2314 |
ceiling.@Chg{Version=[2],New=[ We have an @ImplPermName in |
| 2315 |
@RefSecNum{Entry Queuing Policies} to allow this implementation. We could |
| 2316 |
have required an immediate priority change if on a ready queue during a |
| 2317 |
protected action, but that would have required extra checks for ceiling |
| 2318 |
violations to meet @BoundedName requirements of |
| 2319 |
@RefSecNum{Priority Ceiling Locking} and potentially could cause a protected |
| 2320 |
action to be abandoned in the middle (by raising Program_Error). That seems |
| 2321 |
bad.],Old=[]} |
| 2322 |
@end{ImplNote} |
| 2323 |
@begin{Reason} |
| 2324 |
@Leading@;A previous version of Ada 9X made it a run-time error |
| 2325 |
for a high-priority task to set the priority of a lower-priority |
| 2326 |
task that has a queued call on a protected object with a low ceiling. |
| 2327 |
This was changed because: |
| 2328 |
@begin{Itemize} |
| 2329 |
The check was not feasible to implement on all systems, |
| 2330 |
since priority changes might be deferred due to |
| 2331 |
inter-processor communication overhead. |
| 2332 |
The calling task would continue to execute without finding out whether |
| 2333 |
the operation succeeded or not. |
| 2334 |
|
| 2335 |
The run-time check would tend to cause intermittent system failures @em |
| 2336 |
how is the caller supposed to know whether the other task happens to |
| 2337 |
have a queued call at any given time? Consider for example an |
| 2338 |
interrupt that needs to trigger a priority change in some task. |
| 2339 |
The interrupt handler could not safely call Set_Priority without knowing |
| 2340 |
exactly what the other task is doing, |
| 2341 |
or without severely restricting the ceilings used in the system. |
| 2342 |
If the interrupt handler wants to hand the job off to a third task whose |
| 2343 |
job is to call Set_Priority, this won't help, because one would normally |
| 2344 |
want the third task to have high priority. |
| 2345 |
@end{Itemize} |
| 2346 |
@end{Reason} |
| 2347 |
@end{RunTime} |
| 2348 |
|
| 2349 |
@begin{Bounded} |
| 2350 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00327-01]} |
| 2351 |
@ChgDeleted{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 2352 |
If a task is blocked on a protected entry call, and the call is queued, |
| 2353 |
it is a bounded error to raise its base priority |
| 2354 |
above the ceiling priority of the corresponding |
| 2355 |
protected object. |
| 2356 |
When an entry call is cancelled, it is a bounded error |
| 2357 |
if the priority of the calling task is higher than |
| 2358 |
the ceiling priority of the corresponding |
| 2359 |
protected object. |
| 2360 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)} |
| 2361 |
In either of these cases, |
| 2362 |
either Program_Error is raised in the task that called the entry, |
| 2363 |
or its priority is temporarily lowered, |
| 2364 |
or both, or neither.]} |
| 2365 |
@begin{Ramification} |
| 2366 |
@ChgRef{Version=[2],Kind=[Deleted]} |
| 2367 |
@ChgDeleted{Version=[2],Text=[Note that the error is @lquotes@;blamed@rquotes@; on the task that did the entry call, |
| 2368 |
not the task that called Set_Priority. |
| 2369 |
This seems to make sense for the case of a task blocked on a call, |
| 2370 |
since if the Set_Priority had happened a |
| 2371 |
little bit sooner, before the task queued a call, |
| 2372 |
the entry-calling task would get the error. |
| 2373 |
In the other case, there is no reason not to raise the priority of a |
| 2374 |
task that is executing in an @nt{abortable_part}, so long as its |
| 2375 |
priority is lowered before it gets to the end and needs to cancel the |
| 2376 |
call. |
| 2377 |
The priority might need to be lowered to allow it to remove the call |
| 2378 |
from the entry queue, |
| 2379 |
in order to avoid violating the ceiling. |
| 2380 |
This seems relatively harmless, since there is an error, |
| 2381 |
and the task is about to start raising an exception anyway.]} |
| 2382 |
@end{Ramification} |
| 2383 |
@end{Bounded} |
| 2384 |
|
| 2385 |
@begin{Erron} |
| 2386 |
@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 2387 |
If any subprogram in this package is called with a parameter T that |
| 2388 |
specifies a task object that no longer exists, the execution of the |
| 2389 |
program is erroneous. |
| 2390 |
@begin{Ramification} |
| 2391 |
Note that this rule overrides the above rule saying that |
| 2392 |
Program_Error is raised on Get_Priority of a terminated task. |
| 2393 |
If the task object still exists, and the task is terminated, |
| 2394 |
Get_Priority raises Program_Error. |
| 2395 |
However, if the task object no longer exists, |
| 2396 |
calling Get_Priority causes erroneous execution. |
| 2397 |
@end{Ramification} |
| 2398 |
@end{Erron} |
| 2399 |
|
| 2400 |
@begin{DocReq} |
| 2401 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00188-02]} |
| 2402 |
@ChgAdded{Version=[2],Text=[On a multiprocessor, the implementation shall |
| 2403 |
document any conditions that cause the completion of the setting of the |
| 2404 |
priority of a task to be delayed later than what is specified for a |
| 2405 |
single processor.]} |
| 2406 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 2407 |
Text=[Any conditions that cause the completion of the setting of the priority |
| 2408 |
of a task to be delayed for a multiprocessor.]}]} |
| 2409 |
@end{DocReq} |
| 2410 |
|
| 2411 |
@begin{Metrics} |
| 2412 |
@Leading@;The implementation shall document the following metric: |
| 2413 |
@begin{Itemize} |
| 2414 |
The execution time of a call to Set_Priority, for the nonpreempting case, |
| 2415 |
in processor clock cycles. This is measured for a call that modifies the |
| 2416 |
priority of a ready task that is not running (which |
| 2417 |
cannot be the calling one), where the new |
| 2418 |
base priority of the affected task is lower than the active priority of the |
| 2419 |
calling task, and the affected task is not on any entry queue and is not |
| 2420 |
executing a protected operation. |
| 2421 |
@end{Itemize} |
| 2422 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2423 |
Text=[The metrics for Set_Priority.]}]} |
| 2424 |
@end{Metrics} |
| 2425 |
|
| 2426 |
@begin{Notes} |
| 2427 |
|
| 2428 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]} |
| 2429 |
Setting a task's base priority affects task dispatching. First, it can |
| 2430 |
change the task's active priority. Second, under the @Chg{Version=[2], |
| 2431 |
New=[FIFO_Within_Priorities],Old=[standard |
| 2432 |
task dispatching]} policy it always causes the task to move to |
| 2433 |
the tail of the ready queue corresponding to its active priority, |
| 2434 |
even if the new base priority is unchanged. |
| 2435 |
|
| 2436 |
Under the priority queuing policy, setting a task's base |
| 2437 |
priority has an effect on a queued entry call |
| 2438 |
if the task is blocked waiting for the call. That is, setting the |
| 2439 |
base priority of a task causes the priority of a queued entry |
| 2440 |
call from that task to be updated and the call to be removed and |
| 2441 |
then reinserted in the entry queue at the new priority |
| 2442 |
(see @RefSecNum{Entry Queuing Policies}), |
| 2443 |
unless the call originated from the @nt{triggering_statement} of an |
| 2444 |
@nt{asynchronous_select}. |
| 2445 |
|
| 2446 |
The effect of two or more Set_Priority calls executed in parallel on |
| 2447 |
the same task is defined as executing these calls in some serial order. |
| 2448 |
|
| 2449 |
@begin{TheProof} |
| 2450 |
This follows from the general reentrancy requirements stated near the |
| 2451 |
beginning of @RefSec{Predefined Language Environment}. |
| 2452 |
@end{TheProof} |
| 2453 |
|
| 2454 |
The rule for when Tasking_Error is raised for Set_Priority or Get_Priority is |
| 2455 |
different from the rule for when Tasking_Error is raised on an |
| 2456 |
entry call (see @RefSecNum{Entry Calls}). In particular, setting or |
| 2457 |
querying the priority of a completed or an abnormal |
| 2458 |
task is allowed, so long as the task is not yet terminated. |
| 2459 |
|
| 2460 |
Changing the priorities of a set of tasks can be performed by a |
| 2461 |
series of calls to Set_Priority for each task separately. For |
| 2462 |
this to work reliably, it should be done within a protected |
| 2463 |
operation that has high enough ceiling priority to guarantee that |
| 2464 |
the operation completes without being preempted by any of the |
| 2465 |
affected tasks. |
| 2466 |
|
| 2467 |
@end{Notes} |
| 2468 |
|
| 2469 |
@begin{Extend95} |
| 2470 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00188-02]} |
| 2471 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2472 |
@b[Amendment Correction:] Priority changes are |
| 2473 |
now required to be done immediately so long as the target task is not on an |
| 2474 |
entry queue.]} |
| 2475 |
|
| 2476 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 2477 |
@ChgAdded{Version=[2],Text=[Dynamic_Priorities is now Preelaborated, |
| 2478 |
so it can be used in preelaborated units.]} |
| 2479 |
@end{Extend95} |
| 2480 |
|
| 2481 |
@begin{DiffWord95} |
| 2482 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2483 |
@ChgAdded{Version=[2],Text=[This Ada 95 clause was turned into a subclause. |
| 2484 |
The paragraph numbers are the same as those for |
| 2485 |
@RefSecNum{Dynamic Priorities} in Ada 95.]} |
| 2486 |
|
| 2487 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]} |
| 2488 |
@ChgAdded{Version=[2],Text=[There is no @lquotes@;standard@rquotes policy |
| 2489 |
anymore, so that phrase was replaced by the name of a specific policy in |
| 2490 |
the notes.]} |
| 2491 |
|
| 2492 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2493 |
@ChgAdded{Version=[2],Text=[The bounded error for the priority of a task |
| 2494 |
being higher than the ceiling of an object it is currently in was moved |
| 2495 |
to @RefSecNum{Priority Ceiling Locking}, so that it applies no matter how |
| 2496 |
the situation arises.]} |
| 2497 |
@end{DiffWord95} |
| 2498 |
|
| 2499 |
|
| 2500 |
@RMNewPage@Comment{For printed Ada 2005 RM} |
| 2501 |
@LabeledAddedSubClause{Version=[2],Name=[Dynamic Priorities for Protected Objects]} |
| 2502 |
|
| 2503 |
@begin{Intro} |
| 2504 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2505 |
@ChgAdded{Version=[2],Text=[This clause specifies how the priority of a |
| 2506 |
protected object can be modified or queried at run time.]} |
| 2507 |
@end{Intro} |
| 2508 |
|
| 2509 |
@begin{StaticSem} |
| 2510 |
|
| 2511 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2512 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The following attribute |
| 2513 |
is defined for @PrefixType{a @nt{prefix} P that denotes a protected object}:]} |
| 2514 |
|
| 2515 |
@begin(Description) |
| 2516 |
@ChgAttribute{Version=[2],Kind=[AddedNormal],ChginAnnex=[T], |
| 2517 |
Leading=<F>, Prefix=<P>, AttrName=<Priority>, ARef=[AI95-00327-01], |
| 2518 |
Text=[@Chg{Version=[2],New=[Denotes a non-aliased component of the |
| 2519 |
protected object P. This component is of type System.Any_Priority and its |
| 2520 |
value is the priority of P. P'Priority denotes a variable if and only if P |
| 2521 |
denotes a variable. A reference to this attribute shall appear only |
| 2522 |
within the body of P.],Old=[]}]} |
| 2523 |
@EndPrefixType{} |
| 2524 |
@end{Description} |
| 2525 |
|
| 2526 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2527 |
@ChgAdded{Version=[2],Text=[The initial value of this attribute is |
| 2528 |
the initial value of the priority of the protected object@Redundant[, and can |
| 2529 |
be changed by an assignment].]} |
| 2530 |
@end{StaticSem} |
| 2531 |
|
| 2532 |
@begin{Runtime} |
| 2533 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2534 |
@ChgAdded{Version=[2],Text=[If the locking policy Ceiling_Locking (see |
| 2535 |
@RefSecNum{Priority Ceiling Locking}) is in effect |
| 2536 |
then the ceiling priority of a protected object @i<P> is set to the value of |
| 2537 |
@i<P>'Priority at the end of each protected action of @i<P>.]} |
| 2538 |
|
| 2539 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00445-01]} |
| 2540 |
@ChgAdded{Version=[2],Text=[If the locking policy Ceiling_Locking is in effect, |
| 2541 |
then for a protected object @i<P> with either an Attach_Handler or |
| 2542 |
Interrupt_Handler pragma applying to one of its procedures, a check is made |
| 2543 |
that the value to be assigned to @i<P>'Priority is in the range |
| 2544 |
System.Interrupt_Priority. If the check fails, Program_Error is |
| 2545 |
raised.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]} |
| 2546 |
@end{Runtime} |
| 2547 |
|
| 2548 |
@begin{Metrics} |
| 2549 |
|
| 2550 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2551 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The implementation shall document |
| 2552 |
the following metric:]} |
| 2553 |
|
| 2554 |
@begin{Itemize} |
| 2555 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2556 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The difference in execution time of |
| 2557 |
calls to the following procedures in protected object P:]} |
| 2558 |
|
| 2559 |
@begin{Example} |
| 2560 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2561 |
@ChgAdded{Version=[2],Text=[@key<protected> P @key<is> |
| 2562 |
@key<procedure> Do_Not_Set_Ceiling (Pr : System.Any_Priority); |
| 2563 |
@key<procedure> Set_Ceiling (Pr : System.Any_Priority); |
| 2564 |
@key<end> P;]} |
| 2565 |
|
| 2566 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2567 |
@ChgAdded{Version=[2],Text=[@key<protected body> P @key<is> |
| 2568 |
@key<procedure> Do_Not_Set_Ceiling (Pr : System.Any_Priority) @key<is> |
| 2569 |
@key<begin> |
| 2570 |
@key<null>; |
| 2571 |
@key<end>; |
| 2572 |
@key<procedure> Set_Ceiling (Pr : System.Any_Priority) @key<is> |
| 2573 |
@key<begin> |
| 2574 |
P'Priority := Pr; |
| 2575 |
@key<end>; |
| 2576 |
@key<end> P;]} |
| 2577 |
@end{Example} |
| 2578 |
@end{Itemize} |
| 2579 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2580 |
Text=[The metrics for setting the priority of a protected object.]}]} |
| 2581 |
@end{Metrics} |
| 2582 |
|
| 2583 |
@begin{Notes} |
| 2584 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2585 |
@ChgAdded{Version=[2],Text=[Since P'Priority is a normal variable, the value |
| 2586 |
following an assignment to the attribute immediately reflects the new value |
| 2587 |
even though its impact on the ceiling priority of P is postponed until |
| 2588 |
completion of the protected action in which it is executed.]} |
| 2589 |
@end{Notes} |
| 2590 |
|
| 2591 |
@begin{Extend95} |
| 2592 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01],ARef=[AI95-00445-01]} |
| 2593 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2594 |
The ability to dynamically change and query the priority of a protected |
| 2595 |
object is new.]} |
| 2596 |
@end{Extend95} |
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
@RMNewPage@Comment{For printed RM Ada 2005 only} |
| 2601 |
@LabeledClause{Preemptive Abort} |
| 2602 |
|
| 2603 |
@begin{Intro} |
| 2604 |
@Redundant[This clause specifies requirements on the immediacy with |
| 2605 |
which an aborted construct is completed.] |
| 2606 |
@end{Intro} |
| 2607 |
|
| 2608 |
@begin{RunTime} |
| 2609 |
|
| 2610 |
On a system with a single processor, an aborted construct is completed |
| 2611 |
immediately at the first point that is outside the execution of an |
| 2612 |
abort-deferred operation. |
| 2613 |
|
| 2614 |
@end{RunTime} |
| 2615 |
|
| 2616 |
@begin{DocReq} |
| 2617 |
On a multiprocessor, the implementation shall document any conditions that |
| 2618 |
cause the completion of an aborted construct to be delayed later than |
| 2619 |
what is specified for a single processor. |
| 2620 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 2621 |
Text=[On a multiprocessor, any conditions that |
| 2622 |
cause the completion of an aborted construct to be delayed later than |
| 2623 |
what is specified for a single processor.]}]} |
| 2624 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2625 |
Text=[On a multiprocessor, any conditions that |
| 2626 |
cause the completion of an aborted construct to be delayed later than |
| 2627 |
what is specified for a single processor.]}]} |
| 2628 |
@end{DocReq} |
| 2629 |
|
| 2630 |
@begin{Metrics} |
| 2631 |
@Leading@;The implementation shall document the following metrics: |
| 2632 |
@begin{Itemize} |
| 2633 |
The execution time, in processor clock cycles, that it takes for an |
| 2634 |
@nt{abort_statement} to cause the completion of the aborted task. |
| 2635 |
This is measured in a situation where a task T2 preempts task T1 |
| 2636 |
and aborts T1. T1 does not have any finalization code. T2 shall |
| 2637 |
verify that T1 has terminated, by means of the Terminated attribute. |
| 2638 |
|
| 2639 |
On a multiprocessor, an upper bound in seconds, |
| 2640 |
on the time that the completion of an aborted task can be delayed beyond |
| 2641 |
the point that it is required for a single processor. |
| 2642 |
|
| 2643 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 2644 |
An upper bound on the execution time of an |
| 2645 |
@nt{asynchronous_select}, in processor clock cycles. This is measured |
| 2646 |
between a point immediately before a task |
| 2647 |
T1 executes a protected operation Pr.Set that makes the @nt{condition} |
| 2648 |
of an @nt{entry_barrier} Pr.Wait @Chg{Version=[2], |
| 2649 |
New=[True],Old=[true]}, and the point where task T2 resumes |
| 2650 |
execution immediately after an entry call to Pr.Wait in an |
| 2651 |
@nt{asynchronous_select}. T1 preempts T2 while |
| 2652 |
T2 is executing the abortable part, and then blocks itself so that |
| 2653 |
T2 can execute. The execution time of T1 is measured separately, |
| 2654 |
and subtracted. |
| 2655 |
|
| 2656 |
An upper bound on the execution time of an |
| 2657 |
@nt{asynchronous_select}, |
| 2658 |
in the case that no asynchronous transfer of control takes |
| 2659 |
place. This is measured between a point immediately before a task |
| 2660 |
executes the @nt{asynchronous_select} with a nonnull abortable |
| 2661 |
part, and the point where the task continues execution immediately after |
| 2662 |
it. The execution time of the abortable part is subtracted. |
| 2663 |
@end{Itemize} |
| 2664 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2665 |
Text=[The metrics for aborts.]}]} |
| 2666 |
@end{Metrics} |
| 2667 |
|
| 2668 |
@begin{ImplAdvice} |
| 2669 |
|
| 2670 |
Even though the @nt{abort_statement} is included in the list of |
| 2671 |
potentially blocking operations |
| 2672 |
(see @RefSecNum{Protected Subprograms and Protected Actions}), |
| 2673 |
it is recommended that this statement be implemented in a way that |
| 2674 |
never requires the task executing the @nt{abort_statement} to |
| 2675 |
block. |
| 2676 |
|
| 2677 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2678 |
Text=[The @nt{abort_statement} should not require the task executing the |
| 2679 |
statement to block.]}]} |
| 2680 |
|
| 2681 |
On a multi-processor, |
| 2682 |
the delay associated with aborting a task on another processor |
| 2683 |
should be bounded; |
| 2684 |
the implementation should use periodic polling, |
| 2685 |
if necessary, to achieve this. |
| 2686 |
|
| 2687 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2688 |
Text=[On a multi-processor, |
| 2689 |
the delay associated with aborting a task on another processor |
| 2690 |
should be bounded.]}]} |
| 2691 |
|
| 2692 |
@end{ImplAdvice} |
| 2693 |
|
| 2694 |
@begin{Notes} |
| 2695 |
|
| 2696 |
Abortion does not change the active or base priority of the aborted task. |
| 2697 |
|
| 2698 |
Abortion cannot be more immediate than is allowed by the rules for |
| 2699 |
deferral of abortion during finalization and in protected actions. |
| 2700 |
|
| 2701 |
@end{Notes} |
| 2702 |
|
| 2703 |
|
| 2704 |
@LabeledClause{Tasking Restrictions} |
| 2705 |
|
| 2706 |
@begin{Intro} |
| 2707 |
@Redundant[This clause defines restrictions that can be used with a |
| 2708 |
pragma Restrictions (see @RefSecNum{Pragma Restrictions}) to facilitate the |
| 2709 |
construction of highly efficient tasking run-time systems.] |
| 2710 |
@end{Intro} |
| 2711 |
|
| 2712 |
@begin{StaticSem} |
| 2713 |
@Leading@;The following @SynI{restriction_}@nt{identifier}s are language defined: |
| 2714 |
@begin{Description} |
| 2715 |
@Defn2{Term=[Restrictions],Sec=(No_Task_Hierarchy)}No_Task_Hierarchy @\All (nonenvironment) tasks depend directly on |
| 2716 |
the environment task of the partition. |
| 2717 |
|
| 2718 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0042],ARef=[AI95-00130-01]} |
| 2719 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00360-01]} |
| 2720 |
@Defn2{Term=[Restrictions],Sec=(No_Nested_Finalization)}No_Nested_Finalization @\Objects |
| 2721 |
@Chg{Version=[2],New=[of a type that needs finalization (see |
| 2722 |
@RefSecNum{User-Defined Assignment and Finalization})],Old=[with |
| 2723 |
controlled@Chg{New=[, protected, or task],Old=[]} parts]} and |
| 2724 |
access types that designate @Chg{Version=[2],New=[a type that needs |
| 2725 |
finalization],Old=[such objects@Chg{New=[,],Old=[]}]} shall be |
| 2726 |
declared only at library level. |
| 2727 |
@begin{Ramification} |
| 2728 |
@ChgRef{Version=[1],Kind=[Deleted],Ref=[8652/0042],ARef=[AI95-00130-01]} |
| 2729 |
@ChgNote{This is no longer true.} |
| 2730 |
@ChgDeleted{Version=[1],Text=[Note that protected types with entries and |
| 2731 |
interrupt-handling protected types have nontrivial finalization actions. |
| 2732 |
However, this restriction does not restrict those things.]} |
| 2733 |
@end{Ramification} |
| 2734 |
|
| 2735 |
@Defn2{Term=[Restrictions],Sec=(No_Abort_Statements)}No_Abort_Statements @\There are no @nt{abort_statement}s, and there are no |
| 2736 |
calls on Task_Identification.Abort_Task. |
| 2737 |
|
| 2738 |
@Defn2{Term=[Restrictions],Sec=(No_Terminate_Alternatives)}No_Terminate_Alternatives @\There are no @nt{selective_accept}s with |
| 2739 |
@nt{terminate_alternative}s. |
| 2740 |
|
| 2741 |
@Defn2{Term=[Restrictions],Sec=(No_Task_Allocators)}No_Task_Allocators @\There are no @nt{allocator}s for task types or types |
| 2742 |
containing task subcomponents. |
| 2743 |
|
| 2744 |
@Defn2{Term=[Restrictions],Sec=(No_Implicit_Heap_Allocations)}No_Implicit_Heap_Allocations @\There are no operations that implicitly require |
| 2745 |
heap storage allocation to be performed by the |
| 2746 |
implementation. The operations that implicitly |
| 2747 |
require heap storage allocation are |
| 2748 |
implementation defined. |
| 2749 |
@ImplDef{Any operations that implicitly |
| 2750 |
require heap storage allocation.} |
| 2751 |
|
| 2752 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]} |
| 2753 |
No_Dynamic_Priorities @\There are no semantic dependences on the package |
| 2754 |
Dynamic_Priorities@Chg{Version=[2],New=[, and no occurrences |
| 2755 |
of the attribute Priority],Old=[]}. |
| 2756 |
@Defn2{Term=[Restrictions],Sec=(No_Dynamic_Priorities)} |
| 2757 |
|
| 2758 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00305-01],ARef=[AI95-00394-01]} |
| 2759 |
@Chg{Version=[2],New=[@Defn2{Term=[Restrictions],Sec=(No_Dynamic_Attachment)}No_Dynamic_Attachment], |
| 2760 |
Old=[@Defn2{Term=[Restrictions],Sec=(No_Asynchronous_Control)}No_Asynchronous_Control]} |
| 2761 |
@\There |
| 2762 |
@Chg{Version=[2],New=[is no call to any of the operations defined |
| 2763 |
in package Interrupts (Is_Reserved, Is_Attached, Current_Handler, |
| 2764 |
Attach_Handler, Exchange_Handler, Detach_Handler, and Reference).], |
| 2765 |
Old=[are no semantic dependences on the package Asynchronous_Task_Control.]} |
| 2766 |
|
| 2767 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2768 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Local_Protected_Objects)}No_Local_Protected_Objects @\Protected |
| 2769 |
objects shall be declared only at library level.]} |
| 2770 |
|
| 2771 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00297-01]} |
| 2772 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Local_Timing_Events)}No_Local_Timing_Events @\Timing_Events |
| 2773 |
shall be declared only at library level.]} |
| 2774 |
|
| 2775 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2776 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Protected_Type_Allocators)}No_Protected_Type_Allocators @\There |
| 2777 |
are no @nt{allocator}s for protected types or types |
| 2778 |
containing protected type subcomponents.]} |
| 2779 |
|
| 2780 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2781 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Relative_Delay)}No_Relative_Delay @\There |
| 2782 |
are no @nt{delay_relative_statement}s.]} |
| 2783 |
|
| 2784 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2785 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Requeue_Statements)}No_Requeue_Statements @\There |
| 2786 |
are no @nt{requeue_statement}s.]} |
| 2787 |
|
| 2788 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2789 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Select_Statements)}No_Select_Statements @\There |
| 2790 |
are no @nt{select_statement}s.]} |
| 2791 |
|
| 2792 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00394-01]} |
| 2793 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Specific_Termination_Handlers)}No_Specific_Termination_Handlers @\There |
| 2794 |
are no calls to the Set_Specific_Handler and Specific_Handler subprograms |
| 2795 |
in Task_Termination.]} |
| 2796 |
|
| 2797 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2798 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(Simple_Barriers)}Simple_Barriers @\The |
| 2799 |
Boolean expression in an entry barrier shall be either a static Boolean |
| 2800 |
expression or a Boolean component of the enclosing protected object.]} |
| 2801 |
|
| 2802 |
@end{Description} |
| 2803 |
|
| 2804 |
@Leading@;The following @SynI{restriction_parameter_}@nt{identifier}s are |
| 2805 |
language defined: |
| 2806 |
@begin{Description} |
| 2807 |
@Defn2{Term=[Restrictions],Sec=(Max_Select_Alternatives)}Max_Select_Alternatives @\Specifies the maximum number of alternatives |
| 2808 |
in a @nt{selective_accept}. |
| 2809 |
|
| 2810 |
@Defn2{Term=[Restrictions],Sec=(Max_Task_Entries)}Max_Task_Entries @\Specifies the maximum number of entries per task. |
| 2811 |
The bounds of every entry family |
| 2812 |
of a task unit shall be static, |
| 2813 |
or shall be defined by a discriminant of a subtype whose |
| 2814 |
corresponding bound is static. |
| 2815 |
@Redundant[A value of zero indicates that no rendezvous |
| 2816 |
are possible.] |
| 2817 |
|
| 2818 |
Max_Protected_Entries @\Specifies the maximum number of entries per |
| 2819 |
protected type. |
| 2820 |
The bounds of every entry family |
| 2821 |
of a protected unit shall be static, |
| 2822 |
or shall be defined by a discriminant of a subtype whose |
| 2823 |
corresponding bound is static. |
| 2824 |
@Defn2{Term=[Restrictions],Sec=(Max_Protected_Entries)} |
| 2825 |
@end{Description} |
| 2826 |
@end{StaticSem} |
| 2827 |
|
| 2828 |
@begin{RunTime} |
| 2829 |
|
| 2830 |
@ChgRef{Version=[1],Kind=[Deleted],Ref=[8652/0076],ARef=[AI95-00067-01]} |
| 2831 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00305-01]} |
| 2832 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The following |
| 2833 |
@SynI{restriction_}@nt{identifier} is language defined:]}@Comment{Use ChgAdded so |
| 2834 |
we get conditional Leading.}@Chg{Version=[1],New=[],Old=[If the following restrictions |
| 2835 |
are violated, the behavior is implementation defined. |
| 2836 |
@IndexCheck{Storage_Check} |
| 2837 |
@Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)} |
| 2838 |
If an implementation chooses to detect such a violation, |
| 2839 |
Storage_Error should be raised.]} |
| 2840 |
|
| 2841 |
@begin{Description} |
| 2842 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01],ARef=[AI95-00394-01]} |
| 2843 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions],Sec=(No_Task_Termination)}No_Task_Termination @\All |
| 2844 |
tasks are non-terminating. It is implementation-defined what happens if |
| 2845 |
a task attempts to terminate. If there is a fall-back handler (see C.7.3) |
| 2846 |
set for the partition it should be called when the first task attempts to |
| 2847 |
terminate.]} |
| 2848 |
@ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 2849 |
Text=[When restriction No_Task_Termination applies to a partition, what |
| 2850 |
happens when a task terminates.]}]} |
| 2851 |
@end{Description} |
| 2852 |
|
| 2853 |
@Leading@;The following @SynI{restriction_parameter_}@nt{identifier}s are |
| 2854 |
language defined: |
| 2855 |
@begin{Description} |
| 2856 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]} |
| 2857 |
@Defn2{Term=[Restrictions],Sec=(Max_Storage_At_Blocking)}Max_Storage_At_Blocking @\Specifies |
| 2858 |
the maximum portion @redundant[(in storage elements)] |
| 2859 |
of a task's Storage_Size that can be retained by a blocked task@Chg{New=[. |
| 2860 |
If an implementation chooses to detect a violation of this |
| 2861 |
restriction, Storage_Error should be raised; |
| 2862 |
@IndexCheck{Storage_Check} |
| 2863 |
@Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)} |
| 2864 |
otherwise, the behavior is implementation defined],Old=[]}. |
| 2865 |
@ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 2866 |
Text=[The behavior when restriction Max_Storage_At_Blocking is violated.]}]} |
| 2867 |
|
| 2868 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]} |
| 2869 |
@Defn2{Term=[Restrictions],Sec=(Max_Asynchronous_Select_Nesting)}Max_Asynchronous_Select_Nesting @\Specifies |
| 2870 |
the maximum dynamic nesting level of @nt{asynchronous_select}s. |
| 2871 |
A value of zero prevents the use of any @nt{asynchronous_@!select}@Chg{New=[ and, |
| 2872 |
if a program contains an @nt{asynchronous_@!select}, it is illegal. |
| 2873 |
@ChgNote{Part of the previous rule is redundant, but it is a different part |
| 2874 |
[all of it for Old; from "prevents" to "and," for New] for each. So we omit it.} |
| 2875 |
If an implementation chooses to detect a violation of this |
| 2876 |
restriction for values other than zero, Storage_Error should be raised; |
| 2877 |
@IndexCheck{Storage_Check} |
| 2878 |
@Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)} |
| 2879 |
otherwise, the behavior is implementation defined],Old=[]}. |
| 2880 |
@ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 2881 |
Text=[The behavior when restriction Max_Asynchronous_Select_Nesting is violated.]}]} |
| 2882 |
|
| 2883 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]} |
| 2884 |
@Defn2{Term=[Restrictions],Sec=(Max_Tasks)}Max_Tasks @\Specifies the maximum |
| 2885 |
number of task creations that may be executed over the lifetime of a |
| 2886 |
partition, not counting the creation of the environment task@Chg{New=[. |
| 2887 |
A value of zero prevents any task creation and, if a program contains a |
| 2888 |
task creation, it is illegal. If an implementation chooses to detect a |
| 2889 |
violation of this restriction, Storage_Error should be raised; |
| 2890 |
@IndexCheck{Storage_Check} |
| 2891 |
@Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)} |
| 2892 |
otherwise, the behavior is implementation defined],Old=[]}. |
| 2893 |
@begin{Ramification} |
| 2894 |
Note that this is not a limit on the |
| 2895 |
number of tasks active at a given time; |
| 2896 |
it is a limit on the total number of task creations that occur. |
| 2897 |
@end{Ramification} |
| 2898 |
@begin{ImplNote} |
| 2899 |
We envision an implementation approach that places TCBs or pointers |
| 2900 |
to them in a fixed-size table, and never reuses table elements. |
| 2901 |
@end{ImplNote} |
| 2902 |
@ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 2903 |
Text=[The behavior when restriction Max_Tasks is violated.]}]} |
| 2904 |
|
| 2905 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]} |
| 2906 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Restrictions], |
| 2907 |
Sec=(Max_Entry_Queue_Length)}Max_Entry_Queue_Length @\Max_Entry_Queue_Length |
| 2908 |
defines the maximum number of calls |
| 2909 |
that are queued on an entry. Violation of this restriction |
| 2910 |
results in the raising of Program_Error at the point of the call or |
| 2911 |
requeue.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]} |
| 2912 |
@end{Description} |
| 2913 |
|
| 2914 |
It is implementation defined whether the use of pragma Restrictions |
| 2915 |
results in a reduction in executable program size, storage requirements, |
| 2916 |
or execution time. If possible, the implementation should provide |
| 2917 |
quantitative descriptions of such effects for each restriction. |
| 2918 |
@ChgImplDef{Version=[2],Kind=[Revised],Text=[@Chg{Version=[2], |
| 2919 |
New=[Whether the use of],Old=[Implementation-defined aspects of]} |
| 2920 |
pragma Restrictions@Chg{Version=[2],New=[ results in a reduction in |
| 2921 |
program code or data size or execution time],Old=[]}.]} |
| 2922 |
@end{RunTime} |
| 2923 |
|
| 2924 |
@begin{ImplAdvice} |
| 2925 |
When feasible, the implementation should take advantage of the specified |
| 2926 |
restrictions to produce a more efficient implementation. |
| 2927 |
|
| 2928 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2929 |
Text=[When feasible, specified restrictions should be used to produce a more |
| 2930 |
efficient implementation.]}]} |
| 2931 |
@end{ImplAdvice} |
| 2932 |
|
| 2933 |
@begin{Notes} |
| 2934 |
The above Storage_Checks can be suppressed with pragma Suppress. |
| 2935 |
@end{Notes} |
| 2936 |
|
| 2937 |
@begin{Incompatible95} |
| 2938 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00360-01]} |
| 2939 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 2940 |
@b[Amendment Correction:] The No_Nested_Finalization is now defined in terms |
| 2941 |
of types that need finalization. These types include a variety of |
| 2942 |
language-defined types that @i<might> be implemented with a controlled type. |
| 2943 |
If the restriction No_Nested_Finalization (see |
| 2944 |
@RefSecNum{Tasking Restrictions}) applies to the partition, and one of these |
| 2945 |
language-defined types does not have a controlled part, it will not be |
| 2946 |
allowed in local objects in Ada 2005 whereas it would be allowed in original |
| 2947 |
Ada 95. Such code is not portable, as other Ada compilers may have had a |
| 2948 |
controlled part, and thus would be illegal under the restriction.]} |
| 2949 |
@end{Incompatible95} |
| 2950 |
|
| 2951 |
@begin{Extend95} |
| 2952 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01],ARef=[AI95-00305-01],ARef=[AI95-00394-01]} |
| 2953 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2954 |
Restrictions No_Dynamic_Attachment, No_Local_Protected_Objects, |
| 2955 |
No_Protected_Type_Allocators, No_Local_Timing_Events, No_Relative_Delay, |
| 2956 |
No_Requeue_Statement, No_Select_Statements, No_Specific_Termination_Handlers, |
| 2957 |
No_Task_Termination, Max_Entry_Queue_Length, and Simple_Barriers are newly |
| 2958 |
added to Ada.]} |
| 2959 |
@end{Extend95} |
| 2960 |
|
| 2961 |
@begin{DiffWord95} |
| 2962 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0042],ARef=[AI95-00130-01]} |
| 2963 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that |
| 2964 |
No_Nested_Finalization covered task and protected parts as well.]} |
| 2965 |
|
| 2966 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0076],ARef=[AI95-00067-01]} |
| 2967 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Changed the description of |
| 2968 |
Max_Tasks and Max_Asynchronous_Select_Nested to eliminate conflicts with the |
| 2969 |
High Integrity Annex (see @RefSecNum{High Integrity Restrictions}).]} |
| 2970 |
|
| 2971 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]} |
| 2972 |
@ChgAdded{Version=[2],Text=[Added using of the new Priority attribute to |
| 2973 |
the restriction No_Dynamic_Priorities.]} |
| 2974 |
|
| 2975 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00394-01]} |
| 2976 |
@ChgAdded{Version=[2],Text=[Restriction No_Asynchronous_Control is now |
| 2977 |
obsolescent.]} |
| 2978 |
@end{DiffWord95} |
| 2979 |
|
| 2980 |
|
| 2981 |
@LabeledClause{Monotonic Time} |
| 2982 |
@begin{Intro} |
| 2983 |
@Redundant[This clause specifies a high-resolution, |
| 2984 |
monotonic clock package.] |
| 2985 |
@end{Intro} |
| 2986 |
|
| 2987 |
@begin{StaticSem} |
| 2988 |
@Leading@;The following language-defined library package exists: |
| 2989 |
@begin{example} |
| 2990 |
@key[package] Ada.Real_Time @key[is]@ChildUnit{Parent=[Ada],Child=[Real_Time]} |
| 2991 |
|
| 2992 |
@key[type] @AdaTypeDefn{Time} @key[is] @key[private]; |
| 2993 |
@AdaObjDefn{Time_First} : @key[constant] Time; |
| 2994 |
@AdaObjDefn{Time_Last} : @key[constant] Time; |
| 2995 |
@AdaObjDefn{Time_Unit} : @key[constant] := @RI{implementation-defined-real-number}; |
| 2996 |
|
| 2997 |
|
| 2998 |
|
| 2999 |
@key[type] @AdaTypeDefn{Time_Span} @key[is] @key[private]; |
| 3000 |
@AdaObjDefn{Time_Span_First} : @key[constant] Time_Span; |
| 3001 |
@AdaObjDefn{Time_Span_Last} : @key[constant] Time_Span; |
| 3002 |
@AdaObjDefn{Time_Span_Zero} : @key[constant] Time_Span; |
| 3003 |
@AdaObjDefn{Time_Span_Unit} : @key[constant] Time_Span; |
| 3004 |
|
| 3005 |
|
| 3006 |
@AdaObjDefn{Tick} : @key[constant] Time_Span; |
| 3007 |
@key[function] @AdaSubDefn{Clock} @key[return] Time; |
| 3008 |
|
| 3009 |
|
| 3010 |
@key[function] "+" (Left : Time; Right : Time_Span) @key[return] Time; |
| 3011 |
@key[function] "+" (Left : Time_Span; Right : Time) @key[return] Time; |
| 3012 |
@key[function] "-" (Left : Time; Right : Time_Span) @key[return] Time; |
| 3013 |
@key[function] "-" (Left : Time; Right : Time) @key[return] Time_Span; |
| 3014 |
|
| 3015 |
|
| 3016 |
@key[function] "<" (Left, Right : Time) @key[return] Boolean; |
| 3017 |
@key[function] "<="(Left, Right : Time) @key[return] Boolean; |
| 3018 |
@key[function] ">" (Left, Right : Time) @key[return] Boolean; |
| 3019 |
@key[function] ">="(Left, Right : Time) @key[return] Boolean; |
| 3020 |
|
| 3021 |
|
| 3022 |
@key[function] "+" (Left, Right : Time_Span) @key[return] Time_Span; |
| 3023 |
@key[function] "-" (Left, Right : Time_Span) @key[return] Time_Span; |
| 3024 |
@key[function] "-" (Right : Time_Span) @key[return] Time_Span; |
| 3025 |
@key[function] "*" (Left : Time_Span; Right : Integer) @key{return} Time_Span; |
| 3026 |
@key[function] "*" (Left : Integer; Right : Time_Span) @key{return} Time_Span; |
| 3027 |
@key[function] "/" (Left, Right : Time_Span) @key[return] Integer; |
| 3028 |
@key[function] "/" (Left : Time_Span; Right : Integer) @key[return] Time_Span; |
| 3029 |
|
| 3030 |
@key[function] "@key[abs]"(Right : Time_Span) @key[return] Time_Span; |
| 3031 |
|
| 3032 |
@ChgRef{Version=[1], Kind=[Deleted]} |
| 3033 |
@Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number from original RM}>] |
| 3034 |
|
| 3035 |
@key[function] "<" (Left, Right : Time_Span) @key[return] Boolean; |
| 3036 |
@key[function] "<="(Left, Right : Time_Span) @key[return] Boolean; |
| 3037 |
@key[function] ">" (Left, Right : Time_Span) @key[return] Boolean; |
| 3038 |
@key[function] ">="(Left, Right : Time_Span) @key[return] Boolean; |
| 3039 |
|
| 3040 |
|
| 3041 |
@key[function] @AdaSubDefn{To_Duration} (TS : Time_Span) @key[return] Duration; |
| 3042 |
@key[function] @AdaSubDefn{To_Time_Span} (D : Duration) @key[return] Time_Span; |
| 3043 |
|
| 3044 |
|
| 3045 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00386-01]} |
| 3046 |
@key[function] @AdaSubDefn{Nanoseconds} (NS : Integer) @key{return} Time_Span; |
| 3047 |
@key[function] @AdaSubDefn{Microseconds} (US : Integer) @key{return} Time_Span; |
| 3048 |
@key[function] @AdaSubDefn{Milliseconds} (MS : Integer) @key{return} Time_Span;@Chg{Version=[2],New=[ |
| 3049 |
@key[function] @AdaSubDefn{Seconds} (S : Integer) @key{return} Time_Span; |
| 3050 |
@key[function] @AdaSubDefn{Minutes} (M : Integer) @key{return} Time_Span;],Old=[]} |
| 3051 |
|
| 3052 |
|
| 3053 |
@key[type] @AdaTypeDefn{Seconds_Count} @key[is] @key[range] @RI{implementation-defined}; |
| 3054 |
|
| 3055 |
@key{procedure} @AdaSubDefn{Split}(T : @key{in} Time; SC : @key{out} Seconds_Count; TS : @key{out} Time_Span); |
| 3056 |
@key{function} @AdaSubDefn{Time_Of}(SC : Seconds_Count; TS : Time_Span) @key{return} Time; |
| 3057 |
|
| 3058 |
@key[private] |
| 3059 |
... -- @RI{not specified by the language} |
| 3060 |
@key[end] Ada.Real_Time; |
| 3061 |
@end{example} |
| 3062 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 3063 |
Text=[Implementation-defined aspects of package Real_Time.]}]} |
| 3064 |
|
| 3065 |
@Defn{real time} |
| 3066 |
In this Annex, @i{real time} is defined to be the physical time as observed |
| 3067 |
in the external environment. |
| 3068 |
The type Time is a @i{time type} as defined by |
| 3069 |
@RefSecNum{Delay Statements, Duration, and Time}; |
| 3070 |
@Redundant[values of this type may be used in a |
| 3071 |
@nt{delay_until_statement}.] |
| 3072 |
Values of this type |
| 3073 |
represent segments of an ideal time line. The set of values of |
| 3074 |
the type Time corresponds one-to-one with an |
| 3075 |
implementation-defined range of mathematical integers. |
| 3076 |
@begin{Discussion} |
| 3077 |
Informally, real time is defined to be the International Atomic Time (TAI) |
| 3078 |
which is monotonic and nondecreasing. We use it here for the purpose of |
| 3079 |
discussing rate of change and monotonic behavior only. It does not imply |
| 3080 |
anything about the absolute value of Real_Time.Clock, or about Real_Time.Time |
| 3081 |
being synchronized with TAI. It is also used for real time in the metrics, |
| 3082 |
for comparison purposes. |
| 3083 |
@end{Discussion} |
| 3084 |
@begin{ImplNote} |
| 3085 |
The specification of TAI as @lquotes@;real time@rquotes@; does not preclude the |
| 3086 |
use of a simulated TAI clock for simulated execution environments. |
| 3087 |
@end{ImplNote} |
| 3088 |
|
| 3089 |
@Defn{epoch} |
| 3090 |
@PDefn{unspecified} |
| 3091 |
The Time value I represents the half-open real time |
| 3092 |
interval that starts with E+I*Time_Unit and is limited by E+(I+1)*Time_Unit, |
| 3093 |
where Time_Unit is an implementation-defined real number and E is an |
| 3094 |
unspecified origin point, the @i{epoch}, that is the same |
| 3095 |
for all values of the type Time. |
| 3096 |
It is not specified by the language whether the time values are |
| 3097 |
synchronized with any standard time reference. |
| 3098 |
@Redundant[For example, E can correspond to the time of system |
| 3099 |
initialization or it can correspond to the epoch of some time standard.] |
| 3100 |
@begin{Discussion} |
| 3101 |
E itself does not have to be a proper time value. |
| 3102 |
|
| 3103 |
This half-open interval I consists of all |
| 3104 |
real numbers R such that E+I*Time_Unit <= R < E+(I+1)*Time_Unit. |
| 3105 |
@end{Discussion} |
| 3106 |
|
| 3107 |
Values of the type Time_Span represent length of real time |
| 3108 |
duration. |
| 3109 |
The set of values of this type corresponds one-to-one |
| 3110 |
with an implementation-defined range of mathematical integers. |
| 3111 |
The Time_Span value corresponding to the integer I |
| 3112 |
represents the real-time duration I*Time_Unit. |
| 3113 |
@begin{Reason} |
| 3114 |
The purpose of this type is similar to Standard.Duration; the idea is to |
| 3115 |
have a type with a higher resolution. |
| 3116 |
@end{Reason} |
| 3117 |
@begin{Discussion} |
| 3118 |
We looked at many possible names for this type: Real_Time.Duration, |
| 3119 |
Fine_Duration, Interval, Time_Interval_Length, Time_Measure, and more. |
| 3120 |
Each of these names had some problems, and we've finally settled for Time_Span. |
| 3121 |
@end{Discussion} |
| 3122 |
|
| 3123 |
Time_First and Time_Last are the smallest and largest values of the |
| 3124 |
Time type, respectively. |
| 3125 |
Similarly, Time_Span_First and Time_Span_Last are the smallest and |
| 3126 |
largest values of the Time_Span type, respectively. |
| 3127 |
|
| 3128 |
A value of type Seconds_Count represents an elapsed time, |
| 3129 |
measured in seconds, |
| 3130 |
since the epoch. |
| 3131 |
|
| 3132 |
@end{StaticSem} |
| 3133 |
|
| 3134 |
@begin{RunTime} |
| 3135 |
|
| 3136 |
Time_Unit is the smallest amount of real time representable by the Time type; |
| 3137 |
it is expressed in seconds. Time_Span_Unit is the difference between |
| 3138 |
two successive values of the Time type. It is also the smallest positive |
| 3139 |
value of type Time_Span. Time_Unit and Time_Span_Unit represent |
| 3140 |
the same real time duration. |
| 3141 |
@Defn{clock tick} |
| 3142 |
A @i{clock tick} is a real time interval during |
| 3143 |
which the clock value (as observed by calling the Clock function) remains |
| 3144 |
constant. Tick is the average length of such intervals. |
| 3145 |
|
| 3146 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00432-01]} |
| 3147 |
The function To_Duration converts the value TS to a value of type |
| 3148 |
Duration. Similarly, the function To_Time_Span converts the value D |
| 3149 |
to a value of type Time_Span. For @Chg{Version=[2],New=[To_Duration], |
| 3150 |
Old=[both operations]}, the result is |
| 3151 |
rounded to the nearest @Chg{Version=[2],New=[value of type Duration], |
| 3152 |
Old=[exactly representable value]} (away from zero if exactly |
| 3153 |
halfway between two @Chg{Version=[2],New=[], |
| 3154 |
Old=[exactly representable ]}values).@Chg{Version=[2],New=[ If the result |
| 3155 |
is outside the range of Duration, Constraint_Error is raised. For To_Time_Span, |
| 3156 |
the value of D is first rounded to the nearest integral multiple of Time_Unit, |
| 3157 |
away from zero if exactly halfway between two multiples. If the |
| 3158 |
rounded value is outside the range of Time_Span, Constraint_Error is |
| 3159 |
raised. Otherwise, the value is converted to the type Time_Span.],Old=[]} |
| 3160 |
|
| 3161 |
To_Duration(Time_Span_Zero) returns 0.0, |
| 3162 |
and To_Time_Span(0.0) returns Time_Span_Zero. |
| 3163 |
|
| 3164 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00386-01],ARef=[AI95-00432-01]} |
| 3165 |
The functions Nanoseconds, Microseconds, @Chg{Version=[2],New=[], |
| 3166 |
Old=[and ]}Milliseconds@Chg{Version=[2],New=[, Seconds, and Minutes],Old=[]} |
| 3167 |
convert the input |
| 3168 |
parameter to a value of the type Time_Span. NS, US,@Chg{Version=[2],New=[],Old=[ and]} |
| 3169 |
MS@Chg{Version=[2],New=[, S, and M],Old=[]} are interpreted as a number of |
| 3170 |
nanoseconds, microseconds,@Chg{Version=[2],New=[],Old=[ and]} |
| 3171 |
milliseconds@Chg{Version=[2],New=[, seconds, and minutes],Old=[]} |
| 3172 |
respectively.@Chg{Version=[2],New=[ The input parameter is first converted to |
| 3173 |
seconds and rounded to the nearest integral multiple of Time_Unit, ], |
| 3174 |
Old=[The result is rounded to the nearest exactly |
| 3175 |
representable value (]}away from zero if exactly halfway between two |
| 3176 |
@Chg{Version=[2],New=[multiples. If the rounded value |
| 3177 |
is outside the range of Time_Span, Constraint_Error is raised. |
| 3178 |
Otherwise, the rounded value is converted to the type Time_Span], |
| 3179 |
Old=[exactly representable values)]}. |
| 3180 |
@begin{Discussion} |
| 3181 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00432-01]} |
| 3182 |
@ChgDeleted{Version=[2],Text=[The above does not imply that the Time_Span |
| 3183 |
type will have to accommodate Integer'Last of milliseconds; Constraint_Error |
| 3184 |
is allowed to be raised.]} |
| 3185 |
@end{Discussion} |
| 3186 |
|
| 3187 |
The effects of the operators on Time and Time_Span are as for the |
| 3188 |
operators defined for integer types. |
| 3189 |
@begin{ImplNote} |
| 3190 |
Though time values are modeled by integers, the types Time and |
| 3191 |
Time_Span need not be implemented as integers. |
| 3192 |
@end{ImplNote} |
| 3193 |
|
| 3194 |
The function Clock returns |
| 3195 |
the amount of time since the epoch. |
| 3196 |
|
| 3197 |
The effects of the Split and Time_Of operations are defined as follows, |
| 3198 |
treating values of type |
| 3199 |
Time, Time_Span, and Seconds_Count as mathematical integers. |
| 3200 |
The effect of Split(T,SC,TS) is to set SC and TS to values |
| 3201 |
such that T*Time_Unit = SC*1.0 + TS*Time_Unit, and 0.0 <= TS*Time_Unit < 1.0. |
| 3202 |
The value returned by Time_Of(SC,TS) is the value T such that T*Time_Unit = |
| 3203 |
SC*1.0 + TS*Time_Unit. |
| 3204 |
@end{RunTime} |
| 3205 |
|
| 3206 |
@begin{ImplReq} |
| 3207 |
|
| 3208 |
The range of Time values shall be sufficient to uniquely |
| 3209 |
represent the range of real times from program start-up to 50 years later. |
| 3210 |
Tick shall be no greater than 1 millisecond. |
| 3211 |
Time_Unit shall be less than or equal to 20 microseconds. |
| 3212 |
@begin{ImplNote} |
| 3213 |
The required range and accuracy of Time are such that |
| 3214 |
32-bits worth of seconds and 32-bits worth of ticks in a second could be |
| 3215 |
used as the representation. |
| 3216 |
@end{ImplNote} |
| 3217 |
|
| 3218 |
Time_Span_First shall be no greater than @en@;3600 seconds, and |
| 3219 |
Time_Span_Last shall be no less than 3600 seconds. |
| 3220 |
@begin{Reason} |
| 3221 |
This is equivalent to @PorM one hour and there is still room for |
| 3222 |
a two-microsecond resolution. |
| 3223 |
@end{Reason} |
| 3224 |
|
| 3225 |
@Defn{clock jump} |
| 3226 |
A @i{clock jump} is the difference between two successive distinct values of |
| 3227 |
the clock (as observed by calling the Clock function). There shall be no |
| 3228 |
backward clock jumps. |
| 3229 |
|
| 3230 |
@end{ImplReq} |
| 3231 |
|
| 3232 |
@begin{DocReq} |
| 3233 |
|
| 3234 |
The implementation shall document the values of Time_First, Time_Last, |
| 3235 |
Time_Span_@!First, Time_Span_@!Last, Time_Span_@!Unit, and Tick. |
| 3236 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3237 |
Text=[The values of Time_First, Time_Last, |
| 3238 |
Time_Span_@!First, Time_Span_@!Last, Time_Span_@!Unit, and Tick |
| 3239 |
for package Real_Time.]}]} |
| 3240 |
|
| 3241 |
The implementation shall document the properties of the underlying |
| 3242 |
time base used for the clock and for type Time, |
| 3243 |
such as the range of values supported |
| 3244 |
and any relevant aspects of the underlying hardware |
| 3245 |
or operating system facilities used. |
| 3246 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3247 |
Text=[The properties of the underlying |
| 3248 |
time base used in package Real_Time.]}]} |
| 3249 |
@begin{Discussion} |
| 3250 |
If there is an underlying operating system, |
| 3251 |
this might include information about which system call is used |
| 3252 |
to implement the clock. |
| 3253 |
Otherwise, it might include information about which |
| 3254 |
hardware clock is used. |
| 3255 |
@end{Discussion} |
| 3256 |
|
| 3257 |
The implementation shall document whether or not there is any synchronization |
| 3258 |
with external time references, and if such synchronization exists, the sources |
| 3259 |
of synchronization information, the frequency of synchronization, and the |
| 3260 |
synchronization method applied. |
| 3261 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3262 |
Text=[Any synchronization of package Real_Time with external time references.]}]} |
| 3263 |
|
| 3264 |
@ChgRef{Version=[1],Kind=[Revised]} |
| 3265 |
The implementation shall document any aspects of the @Chg{New=[], Old=[the]} |
| 3266 |
@chgnote{Correct typo as noted at Potsdam ARG meeting} |
| 3267 |
external environment that could interfere with the clock behavior as defined |
| 3268 |
in this clause. |
| 3269 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3270 |
Text=[Any aspects of the external environment that could interfere with |
| 3271 |
package Real_Time.]}]} |
| 3272 |
@begin{Discussion} |
| 3273 |
For example, the implementation is allowed to rely on the time services of |
| 3274 |
an underlying operating system, and this operating system clock can |
| 3275 |
implement time zones or allow the clock to be reset by an operator. |
| 3276 |
This dependence has to be documented. |
| 3277 |
@end{Discussion} |
| 3278 |
@end{DocReq} |
| 3279 |
|
| 3280 |
@begin{Metrics} |
| 3281 |
For the purpose of the metrics defined in this clause, real time is |
| 3282 |
defined to be the International Atomic Time (TAI). |
| 3283 |
|
| 3284 |
@Leading@;The implementation shall document the following metrics: |
| 3285 |
@begin{Itemize} |
| 3286 |
An upper bound on the real-time duration of a clock tick. This is a value |
| 3287 |
D such that if t1 and t2 are any real times such that t1 < t2 and |
| 3288 |
Clock@-{t1} = Clock@-{t2} then t2 @en@; t1 <= D. |
| 3289 |
|
| 3290 |
An upper bound on the size of a clock jump. |
| 3291 |
|
| 3292 |
@Defn{drift rate} |
| 3293 |
An upper bound on the @i{drift rate} of Clock with respect to real time. |
| 3294 |
This is a real number D such that |
| 3295 |
@begin{display} |
| 3296 |
E*(1@en@;D) <= (Clock@-{t+E} @en@; Clock@-{t}) <= E*(1+D) |
| 3297 |
provided that: Clock@-{t} + E*(1+D) <= Time_Last. |
| 3298 |
@end{display} |
| 3299 |
|
| 3300 |
where Clock@-{t} is the value of Clock at time t, and E is a real |
| 3301 |
time duration not less than 24 hours. The value of E used for |
| 3302 |
this metric shall be reported. |
| 3303 |
@begin{Reason} |
| 3304 |
This metric is intended to provide a measurement |
| 3305 |
of the long term (cumulative) deviation; therefore, 24 |
| 3306 |
hours is the |
| 3307 |
lower bound on the measurement period. On some implementations, |
| 3308 |
this is also the maximum period, since the language does not |
| 3309 |
require that the range of the type Duration be more than 24 hours. |
| 3310 |
On those implementations that support longer-range Duration, longer |
| 3311 |
measurements should be performed. |
| 3312 |
@end{Reason} |
| 3313 |
|
| 3314 |
An upper bound on the execution time of a call to the Clock |
| 3315 |
function, in processor clock cycles. |
| 3316 |
|
| 3317 |
Upper bounds on the execution times of the operators of the types Time |
| 3318 |
and Time_Span, in processor clock cycles. |
| 3319 |
@begin{ImplNote} |
| 3320 |
A fast implementation of the Clock function involves repeated |
| 3321 |
reading until you get the same value twice. |
| 3322 |
It is highly improbable that more than three reads will be necessary. |
| 3323 |
Arithmetic on time values should not be significantly slower |
| 3324 |
than 64-bit arithmetic in the underlying machine instruction set. |
| 3325 |
@end{ImplNote} |
| 3326 |
@end{Itemize} |
| 3327 |
@ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3328 |
Text=[The metrics for package Real_Time.]}]} |
| 3329 |
@end{Metrics} |
| 3330 |
|
| 3331 |
@begin{ImplPerm} |
| 3332 |
Implementations targeted to machines with word size smaller than 32 |
| 3333 |
bits need not support the full range and granularity of the |
| 3334 |
Time and Time_Span types. |
| 3335 |
@begin{Discussion} |
| 3336 |
These requirements are based on machines with a word size of 32 bits. |
| 3337 |
|
| 3338 |
Since the range and granularity are implementation defined, the supported |
| 3339 |
values need to be documented. |
| 3340 |
@end{Discussion} |
| 3341 |
@end{ImplPerm} |
| 3342 |
|
| 3343 |
@begin{ImplAdvice} |
| 3344 |
|
| 3345 |
When appropriate, implementations should provide configuration mechanisms to |
| 3346 |
change the value of Tick. |
| 3347 |
@ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3348 |
Text=[When appropriate, mechanisms to change the value of Tick should be |
| 3349 |
provided.]}]} |
| 3350 |
@begin{Reason} |
| 3351 |
This is often needed when the compilation system was originally targeted to a |
| 3352 |
particular processor with a particular interval timer, but the customer |
| 3353 |
uses the same processor with a different interval timer. |
| 3354 |
@end{Reason} |
| 3355 |
@begin{Discussion} |
| 3356 |
Tick is a deferred constant and not a named number |
| 3357 |
specifically for this purpose. |
| 3358 |
@end{Discussion} |
| 3359 |
@begin{ImplNote} |
| 3360 |
This can be achieved either by pre-run-time configuration |
| 3361 |
tools, or by having Tick be initialized |
| 3362 |
(in the package private part) |
| 3363 |
by a function call residing in a board specific module. |
| 3364 |
@end{ImplNote} |
| 3365 |
|
| 3366 |
It is recommended that Calendar.Clock and Real_Time.Clock be implemented |
| 3367 |
as transformations of the same time base. |
| 3368 |
@ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3369 |
Text=[Calendar.Clock and Real_Time.Clock should be transformations of the |
| 3370 |
same time base.]}]} |
| 3371 |
|
| 3372 |
It is recommended that the @lquotes@;best@rquotes@; time base which exists in the |
| 3373 |
underlying system be available to the application through |
| 3374 |
Clock. @lquotes@;Best@rquotes@; may mean highest accuracy or largest range. |
| 3375 |
@ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 3376 |
Text=[The @lquotes@;best@rquotes@; time base which exists in the |
| 3377 |
underlying system should be available to the application through |
| 3378 |
Real_Time.Clock.]}]} |
| 3379 |
|
| 3380 |
@end{ImplAdvice} |
| 3381 |
|
| 3382 |
@begin{Notes} |
| 3383 |
|
| 3384 |
The rules in this clause do not imply that the implementation can protect |
| 3385 |
the user from operator or installation errors which could result in the |
| 3386 |
clock being set incorrectly. |
| 3387 |
|
| 3388 |
Time_Unit is the granularity of the Time type. In contrast, |
| 3389 |
Tick represents the granularity of Real_Time.Clock. |
| 3390 |
There is no requirement that these be the same. |
| 3391 |
|
| 3392 |
@end{Notes} |
| 3393 |
|
| 3394 |
@begin{Incompatible95} |
| 3395 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00386-01]} |
| 3396 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 3397 |
Functions Seconds and Minutes are newly added to Real_Time. If |
| 3398 |
Real_Time is referenced in a @nt{use_clause}, and an entity @i<E> with a |
| 3399 |
@nt{defining_identifier} of Seconds or Minutes is defined in a package that |
| 3400 |
is also referenced in a @nt{use_clause}, the entity @i<E> may no longer be |
| 3401 |
use-visible, resulting in errors. This should be rare and is easily fixed if |
| 3402 |
it does occur.]} |
| 3403 |
@end{Incompatible95} |
| 3404 |
|
| 3405 |
@begin{DiffWord95} |
| 3406 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00432-01]} |
| 3407 |
@ChgAdded{Version=[2],Text=[Added wording explaining how and when many of |
| 3408 |
these functions can raise Constraint_Error. While there always was an |
| 3409 |
intent to raise Constraint_Error if the values did not fit, there never |
| 3410 |
was any wording to that effect, and since Time_Span was a private type, |
| 3411 |
the normal numeric type rules do not apply to it.]} |
| 3412 |
@end{DiffWord95} |
| 3413 |
|
| 3414 |
|
| 3415 |
@LabeledClause{Delay Accuracy} |
| 3416 |
|
| 3417 |
@begin{Intro} |
| 3418 |
@Redundant[This clause specifies performance requirements for the |
| 3419 |
@nt{delay_statement}. |
| 3420 |
The rules apply both to @nt{delay_@!relative_@!statement} and to |
| 3421 |
@nt{delay_@!until_@!statement}. Similarly, they apply equally to a |
| 3422 |
simple @nt{delay_@!statement} and to one which appears in a |
| 3423 |
@nt{delay_@!alternative}.] |
| 3424 |
@end{Intro} |
| 3425 |
|
| 3426 |
@begin{RunTime} |
| 3427 |
@Leading@;The effect of the @nt{delay_statement} for Real_Time.Time is |
| 3428 |
defined in terms of Real_Time.Clock: |
| 3429 |
@begin{itemize} |
| 3430 |
|
| 3431 |
If C@-{1} is a value of Clock read before a task executes a |
| 3432 |
@nt{delay_relative_statement} with duration D, and C@-{2} is a value of |
| 3433 |
Clock read after the task resumes execution following that |
| 3434 |
@nt{delay_statement}, then C@-{2} @en@; C@-{1} >= D. |
| 3435 |
|
| 3436 |
If C is a value of Clock read after a task resumes execution following a |
| 3437 |
@nt{delay_until_statement} with Real_Time.Time value T, then C >= T. |
| 3438 |
@end{itemize} |
| 3439 |
|
| 3440 |
@PDefn2{Term=[potentially blocking operation],Sec=(delay_statement)} |
| 3441 |
@PDefn2{Term=[blocking, potentially],Sec=(delay_statement)} |
| 3442 |
A simple @nt{delay_statement} with a negative or zero value for the |
| 3443 |
expiration time does not cause the calling task to be blocked; it is |
| 3444 |
nevertheless a potentially blocking operation |
| 3445 |
(see @RefSecNum{Protected Subprograms and Protected Actions}). |
| 3446 |
|
| 3447 |
@ChgRef{Version=[2],Kind=[Revised]} |
| 3448 |
When a @nt{delay_statement} appears in a @nt{delay_alternative} of a |
| 3449 |
@nt{timed_entry_call} the selection of the entry call is attempted, |
| 3450 |
regardless of the specified expiration time. |
| 3451 |
When a @nt{delay_statement} appears in a |
| 3452 |
@Chg{Version=[2],New=[@nt{select_alternative}],Old=[@ntf{selective_accept_alternative}]}, |
| 3453 |
and a call is queued on one of the open entries, the selection of that |
| 3454 |
entry call proceeds, regardless of the value of the delay expression. |
| 3455 |
@begin{Ramification} |
| 3456 |
The effect of these requirements is that one has to always attempt a rendezvous, |
| 3457 |
regardless of the value of the delay expression. This can be tested by |
| 3458 |
issuing a @nt{timed_entry_call} with an expiration time |
| 3459 |
of zero, to an open entry. |
| 3460 |
@end{Ramification} |
| 3461 |
|
| 3462 |
@end{RunTime} |
| 3463 |
|
| 3464 |
@begin{DocReq} |
| 3465 |
|
| 3466 |
The implementation shall document the minimum value of the delay expression |
| 3467 |
of a @nt{delay_relative_statement} that causes the task to actually be blocked. |
| 3468 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3469 |
Text=[The minimum value of the delay expression of a |
| 3470 |
@nt{delay_relative_statement} that causes a task to actually be blocked.]}]} |
| 3471 |
|
| 3472 |
The implementation shall document the minimum difference between the value of |
| 3473 |
the delay expression of a @nt{delay_until_statement} and the value of |
| 3474 |
Real_Time.Clock, that causes the task to actually be blocked. |
| 3475 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 3476 |
Text=[Implementation-defined aspects of @nt{delay_statement}s.]}]} |
| 3477 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3478 |
Text=[The minimum difference between the value of the delay expression of a |
| 3479 |
@nt{delay_until_statement} and the value of Real_Time.Clock, that causes the |
| 3480 |
task to actually be blocked.]}]} |
| 3481 |
|
| 3482 |
@end{DocReq} |
| 3483 |
|
| 3484 |
@begin{Metrics} |
| 3485 |
@Leading@;The implementation shall document the following metrics: |
| 3486 |
@begin{Itemize} |
| 3487 |
An upper bound on the execution time, in processor clock cycles, of a |
| 3488 |
@nt{delay_relative_statement} whose requested value of the delay expression |
| 3489 |
is less than or equal to zero. |
| 3490 |
|
| 3491 |
An upper bound on the execution time, in processor clock cycles, of a |
| 3492 |
@nt{delay_until_statement} whose requested value of the delay expression is |
| 3493 |
less than or equal to the value of Real_Time.Clock at the |
| 3494 |
time of executing the statement. Similarly, for Calendar.Clock. |
| 3495 |
|
| 3496 |
@Defn{lateness} |
| 3497 |
@Defn{actual duration} |
| 3498 |
An upper bound on the @i{lateness} of a @nt{delay_relative_statement}, |
| 3499 |
for a positive value of the delay expression, in a situation |
| 3500 |
where the task has sufficient priority to preempt the processor as |
| 3501 |
soon as it becomes ready, and does not need to |
| 3502 |
wait for any other execution resources. The upper bound is |
| 3503 |
expressed as a function of the value of the delay expression. |
| 3504 |
The lateness is obtained by subtracting the value of the delay expression |
| 3505 |
from the @i{actual duration}. The actual duration is measured from a point |
| 3506 |
immediately before a task executes the @nt{delay_statement} to a point |
| 3507 |
immediately after the task resumes execution following this statement. |
| 3508 |
|
| 3509 |
An upper bound on the lateness of a @nt{delay_until_statement}, in a |
| 3510 |
situation where the value of the requested expiration time is after the time |
| 3511 |
the task begins executing the statement, the task has sufficient priority |
| 3512 |
to preempt the processor as soon as it becomes ready, and |
| 3513 |
it does not need to wait for any other execution resources. The upper |
| 3514 |
bound is expressed as a function of the difference between the requested |
| 3515 |
expiration time and the clock value at the time the statement begins |
| 3516 |
execution. The lateness of a @nt{delay_until_statement} is obtained by |
| 3517 |
subtracting the requested expiration time from the real time that the task |
| 3518 |
resumes execution following this statement. |
| 3519 |
@end{Itemize} |
| 3520 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3521 |
Text=[The metrics for delay statements.]}]} |
| 3522 |
@end{Metrics} |
| 3523 |
|
| 3524 |
@begin{Notes} |
| 3525 |
|
| 3526 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00355-01]} |
| 3527 |
@ChgDeleted{Version=[2],Text=[The execution time of a @nt{delay_statement} that |
| 3528 |
does not cause the task to be blocked (e.g. @lquotes@;@key[delay] |
| 3529 |
0.0;@rquotes@; ) is of interest in situations where delays are used to achieve |
| 3530 |
voluntary round-robin task dispatching among equal-priority tasks.]} |
| 3531 |
|
| 3532 |
@end{Notes} |
| 3533 |
|
| 3534 |
@begin{DiffWord83} |
| 3535 |
|
| 3536 |
The rules regarding a @nt{timed_entry_call} with a very small positive |
| 3537 |
Duration value, have been tightened to always require the check whether |
| 3538 |
the rendezvous is immediately possible. |
| 3539 |
|
| 3540 |
@end{DiffWord83} |
| 3541 |
|
| 3542 |
@begin{DiffWord95} |
| 3543 |
|
| 3544 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]} |
| 3545 |
@ChgAdded{Version=[2],Text=[The note about @lquotes@;voluntary |
| 3546 |
round-robin@rquote, while still true, has been deleted as potentially |
| 3547 |
confusing as it is describing a different kind of round-robin than is defined |
| 3548 |
by the round-robin dispatching policy.]} |
| 3549 |
|
| 3550 |
@end{DiffWord95} |
| 3551 |
|
| 3552 |
|
| 3553 |
@LabeledClause{Synchronous Task Control} |
| 3554 |
|
| 3555 |
@begin{Intro} |
| 3556 |
@Redundant[This clause describes a language-defined private semaphore |
| 3557 |
(suspension object), which can be used for @i{two-stage suspend} |
| 3558 |
operations and as a simple building block for implementing higher-level |
| 3559 |
queues.] |
| 3560 |
@end{Intro} |
| 3561 |
|
| 3562 |
@begin{StaticSem} |
| 3563 |
|
| 3564 |
@Leading@;The following language-defined package exists: |
| 3565 |
@begin{example} |
| 3566 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]} |
| 3567 |
@key{package} Ada.Synchronous_Task_Control @key{is}@ChildUnit{Parent=[Ada],Child=[Synchronous_Task_Control]}@Chg{Version=[2],New=[ |
| 3568 |
@key[pragma] Preelaborate(Synchronous_Task_Control);],Old=[]} |
| 3569 |
|
| 3570 |
@key{type} @AdaTypeDefn{Suspension_Object} @key{is} @key{limited} @key{private}; |
| 3571 |
@key{procedure} @AdaSubDefn{Set_True}(S : @key{in} @key{out} Suspension_Object); |
| 3572 |
@key{procedure} @AdaSubDefn{Set_False}(S : @key{in} @key{out} Suspension_Object); |
| 3573 |
@key{function} @AdaSubDefn{Current_State}(S : Suspension_Object) @key{return} Boolean; |
| 3574 |
@key{procedure} @AdaSubDefn{Suspend_Until_True}(S : @key{in} @key{out} Suspension_Object); |
| 3575 |
@key{private} |
| 3576 |
... -- @RI{not specified by the language} |
| 3577 |
@key{end} Ada.Synchronous_Task_Control; |
| 3578 |
@end{example} |
| 3579 |
|
| 3580 |
The type Suspension_Object is a by-reference type.@begin{ImplNote} |
| 3581 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00318-02]}@ChgNote{This is a real term now, let's get it right} |
| 3582 |
The implementation can ensure this by, for example, making the full view |
| 3583 |
@Chg{Version=[2],New=[an explicitly],Old=[a]} |
| 3584 |
limited record type.@end{implnote} |
| 3585 |
|
| 3586 |
@end{StaticSem} |
| 3587 |
|
| 3588 |
@begin{RunTime} |
| 3589 |
|
| 3590 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 3591 |
An object of the type Suspension_Object has two visible states: |
| 3592 |
@Chg{Version=[2],New=[True],Old=[true]} and |
| 3593 |
@Chg{Version=[2],New=[False],Old=[false]}. Upon initialization, |
| 3594 |
its value is set to @Chg{Version=[2],New=[False],Old=[false]}. |
| 3595 |
@begin{Discussion} |
| 3596 |
This object is assumed to be private to the declaring task, i.e. only that |
| 3597 |
task will call Suspend_Until_True on this object, and the count of callers is |
| 3598 |
at most one. Other tasks can, of course, change and query the state of this |
| 3599 |
object. |
| 3600 |
@end{Discussion} |
| 3601 |
|
| 3602 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 3603 |
The operations Set_True and Set_False are atomic with respect to each other |
| 3604 |
and with respect to Suspend_Until_True; they set the state to |
| 3605 |
@Chg{Version=[2],New=[True],Old=[true]} and |
| 3606 |
@Chg{Version=[2],New=[False],Old=[false]} respectively. |
| 3607 |
|
| 3608 |
Current_State returns the current state of the object. |
| 3609 |
@begin{Discussion} |
| 3610 |
This state can change immediately after the operation returns. |
| 3611 |
@end{Discussion} |
| 3612 |
|
| 3613 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 3614 |
The procedure Suspend_Until_True blocks the calling task until the |
| 3615 |
state of the object S is @Chg{Version=[2],New=[True],Old=[true]}; at that |
| 3616 |
point the task becomes ready |
| 3617 |
and the state of the object becomes @Chg{Version=[2],New=[False],Old=[false]}. |
| 3618 |
|
| 3619 |
@PDefn2{Term=[potentially blocking operation],Sec=(Suspend_Until_True)} |
| 3620 |
@PDefn2{Term=[blocking, potentially],Sec=(Suspend_Until_True)} |
| 3621 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)} |
| 3622 |
Program_Error is raised upon calling Suspend_Until_True if another |
| 3623 |
task is already waiting on that suspension object. |
| 3624 |
Suspend_Until_True is a potentially blocking operation |
| 3625 |
(see @RefSecNum{Protected Subprograms and Protected Actions}). |
| 3626 |
@end{RunTime} |
| 3627 |
|
| 3628 |
@begin{ImplReq} |
| 3629 |
|
| 3630 |
The implementation is required to allow the calling of Set_False and |
| 3631 |
Set_True during any protected action, even one that has its ceiling priority |
| 3632 |
in the Interrupt_Priority range. |
| 3633 |
|
| 3634 |
@end{ImplReq} |
| 3635 |
|
| 3636 |
@begin{Extend95} |
| 3637 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 3638 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 3639 |
Synchronous_Task_Control is now Preelaborated, |
| 3640 |
so it can be used in preelaborated units.]} |
| 3641 |
@end{Extend95} |
| 3642 |
|
| 3643 |
|
| 3644 |
|
| 3645 |
@LabeledClause{Asynchronous Task Control} |
| 3646 |
|
| 3647 |
@begin{Intro} |
| 3648 |
@Redundant[This clause introduces a language-defined package to do |
| 3649 |
asynchronous suspend/resume on tasks. |
| 3650 |
It uses a conceptual @i{held priority} value to represent the task's |
| 3651 |
@i{held} state.] |
| 3652 |
@end{Intro} |
| 3653 |
|
| 3654 |
@begin{StaticSem} |
| 3655 |
|
| 3656 |
@Leading@;The following language-defined library package exists: |
| 3657 |
@begin{example} |
| 3658 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]} |
| 3659 |
@key{with} Ada.Task_Identification; |
| 3660 |
@key{package} Ada.Asynchronous_Task_Control @key{is}@ChildUnit{parent=[Ada],Child=[Asynchronous_Task_Control]}@Chg{Version=[2],New=[ |
| 3661 |
@key[pragma] Preelaborate(Asynchronous_Task_Control);],Old=[]} |
| 3662 |
@key{procedure} @AdaSubDefn{Hold}(T : @key[in] Ada.Task_Identification.Task_Id); |
| 3663 |
@key{procedure} @AdaSubDefn{Continue}(T : @key[in] Ada.Task_Identification.Task_Id); |
| 3664 |
@key{function} @AdaSubDefn{Is_Held}(T : Ada.Task_Identification.Task_Id) |
| 3665 |
@key{return} Boolean; |
| 3666 |
@key{end} Ada.Asynchronous_Task_Control; |
| 3667 |
@end{example} |
| 3668 |
|
| 3669 |
@end{StaticSem} |
| 3670 |
|
| 3671 |
@begin{RunTime} |
| 3672 |
|
| 3673 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]} |
| 3674 |
@PDefn2{Term=[task state], Sec=(held)} |
| 3675 |
@Defn{held priority} |
| 3676 |
@Defn{idle task} |
| 3677 |
After the Hold operation has been applied to a task, the task becomes |
| 3678 |
@i{held}. For each processor there is a conceptual @i{idle task}, |
| 3679 |
which is always ready. The base priority of the idle task is below |
| 3680 |
System.@!Any_@!Priority'First. The @i{held priority} is a |
| 3681 |
constant of the type @Chg{Version=[2],New=[Integer],Old=[integer]} |
| 3682 |
whose value is below the base priority of the idle task. |
| 3683 |
@begin{Discussion} |
| 3684 |
The held state should not be confused with the blocked state as defined |
| 3685 |
in @RefSecNum{Task Execution - Task Activation}; the task is still ready. |
| 3686 |
@end{Discussion} |
| 3687 |
|
| 3688 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00357-01]} |
| 3689 |
@ChgAdded{Version=[2],Text=[For any priority below System.Any_Priority'First, |
| 3690 |
the task dispatching policy is FIFO_Within_Priorities.]} |
| 3691 |
@begin{Honest} |
| 3692 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3693 |
@ChgAdded{Version=[2],Text=[This applies even if a Task_Dispatching_Policy |
| 3694 |
specifies the policy for all of the priorities of the partition.]} |
| 3695 |
@end{Honest} |
| 3696 |
@begin{Ramification} |
| 3697 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3698 |
@ChgAdded{Version=[2],Text=[A task at the held priority never runs, so it is |
| 3699 |
not necessary to implement FIFO_Within_Priorities for systems that have only |
| 3700 |
one policy (such as EDF_Across_Priorities).]} |
| 3701 |
@end{Ramification} |
| 3702 |
|
| 3703 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]} |
| 3704 |
The Hold operation sets the state of T to held. For a held |
| 3705 |
task@Chg{Version=[2],New=[, the active |
| 3706 |
priority is reevaluated as if the base priority of the task were the held |
| 3707 |
priority],Old=[: the task's own base priority does not constitute an |
| 3708 |
inheritance source |
| 3709 |
(see @RefSecNum{Task Priorities}), and the value of the held priority |
| 3710 |
is defined to be such a source instead]}. |
| 3711 |
@begin{Ramification} |
| 3712 |
For example, if T is currently inheriting priorities from other sources (e.g. |
| 3713 |
it is executing in a protected action), its active priority does not change, |
| 3714 |
and it continues to execute until it leaves the protected action. |
| 3715 |
@end{Ramification} |
| 3716 |
|
| 3717 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]} |
| 3718 |
The Continue operation resets the state of T to not-held; |
| 3719 |
@Chg{Version=[2],New=[its],Old=[T's]} active priority |
| 3720 |
is then reevaluated as @Chg{Version=[2],New=[determined by the |
| 3721 |
task dispatching policy associated with its base priority.],Old=[described in |
| 3722 |
@RefSecNum{Task Priorities}. |
| 3723 |
@Redundant[This time, T's base priority is taken into account.]]} |
| 3724 |
|
| 3725 |
The Is_Held function returns True if and only if T is in the held state. |
| 3726 |
@begin{Discussion} |
| 3727 |
Note that the state of T can be changed immediately after Is_Held returns. |
| 3728 |
@end{Discussion} |
| 3729 |
|
| 3730 |
As part of these operations, a check is made that the task |
| 3731 |
identified by |
| 3732 |
T is not terminated. |
| 3733 |
@Defn2{Term=[Tasking_Error],Sec=(raised by failure of run-time check)} |
| 3734 |
Tasking_Error is raised if the check fails. |
| 3735 |
@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)} |
| 3736 |
Program_Error is raised if the value of T is Null_Task_Id. |
| 3737 |
|
| 3738 |
@end{RunTime} |
| 3739 |
|
| 3740 |
@begin{Erron} |
| 3741 |
@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 3742 |
If any operation in this package is called with a parameter T that |
| 3743 |
specifies a task object that no longer exists, the execution of the |
| 3744 |
program is erroneous. |
| 3745 |
@end{Erron} |
| 3746 |
|
| 3747 |
@begin{ImplPerm} |
| 3748 |
|
| 3749 |
An implementation need not support Asynchronous_Task_Control if it is |
| 3750 |
infeasible to support it in the target environment. |
| 3751 |
@begin{Reason} |
| 3752 |
A direct implementation of the Asynchronous_Task_Control semantics using |
| 3753 |
priorities is not necessarily efficient enough. |
| 3754 |
Thus, we envision implementations that use some other mechanism to set |
| 3755 |
the @lquotes@;held@rquotes@; state. |
| 3756 |
If there is no other such mechanism, |
| 3757 |
support for Asynchronous_Task_Control might be infeasible, |
| 3758 |
because an implementation in terms of priority would require one idle |
| 3759 |
task per processor. |
| 3760 |
On some systems, programs are not supposed to know how many processors |
| 3761 |
are available, |
| 3762 |
so creating enough idle tasks would be problematic. |
| 3763 |
@end{Reason} |
| 3764 |
|
| 3765 |
@end{ImplPerm} |
| 3766 |
|
| 3767 |
@begin{Notes} |
| 3768 |
|
| 3769 |
It is a consequence of the priority rules that held tasks cannot be dispatched |
| 3770 |
on any processor in a partition (unless they are inheriting |
| 3771 |
priorities) since their priorities are defined to be |
| 3772 |
below the priority of any idle task. |
| 3773 |
|
| 3774 |
The effect of calling Get_Priority and Set_Priority on a Held task is the |
| 3775 |
same as on any other task. |
| 3776 |
|
| 3777 |
Calling Hold on a held task or Continue on a non-held task has no effect. |
| 3778 |
|
| 3779 |
@Leading@;The rules affecting queuing are derived from the above rules, in |
| 3780 |
addition to the normal priority rules: |
| 3781 |
@begin{itemize} |
| 3782 |
|
| 3783 |
When a held task is on the ready queue, its priority is so low as to never |
| 3784 |
reach the top of the queue as long as there are other tasks on that queue. |
| 3785 |
|
| 3786 |
If a task is executing in a protected action, inside a rendezvous, or is |
| 3787 |
inheriting priorities from other sources (e.g. when activated), it |
| 3788 |
continues to execute until it is no longer executing the corresponding |
| 3789 |
construct. |
| 3790 |
|
| 3791 |
If a task becomes held while waiting (as a caller) for a rendezvous to |
| 3792 |
complete, the active priority of the accepting task is not affected. |
| 3793 |
|
| 3794 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0077],ARef=[AI95-00111-01]} |
| 3795 |
If a task becomes held while waiting in a @nt{selective_accept}, |
| 3796 |
and a@Chg{New=[n],Old=[]} entry call is issued to one of the open entries, |
| 3797 |
the corresponding @Chg{New=[@nt{accept_@!alternative}],Old=[accept body]} |
| 3798 |
executes. When the rendezvous completes, the active |
| 3799 |
priority of the accepting task is lowered to the held priority |
| 3800 |
(unless it is still inheriting from other sources), and the task does |
| 3801 |
not execute until another Continue. |
| 3802 |
|
| 3803 |
The same holds if the held task is the only task on a protected entry queue |
| 3804 |
whose barrier becomes open. The corresponding entry body executes. |
| 3805 |
|
| 3806 |
@end{itemize} |
| 3807 |
|
| 3808 |
@end{Notes} |
| 3809 |
|
| 3810 |
@begin{Extend95} |
| 3811 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 3812 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 3813 |
Asynchronous_Task_Control is now Preelaborated, |
| 3814 |
so it can be used in preelaborated units.]} |
| 3815 |
@end{Extend95} |
| 3816 |
|
| 3817 |
@begin{DiffWord95} |
| 3818 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0077],ARef=[AI95-00111-01]} |
| 3819 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected to eliminate the |
| 3820 |
use of the undefined term @lquotes@;accept body@rquotes@;.]} |
| 3821 |
|
| 3822 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]} |
| 3823 |
@ChgAdded{Version=[2],Text=[The description of held tasks was changed to |
| 3824 |
reflect that the calculation of active priorities depends on the |
| 3825 |
dispatching policy of the base priority. Thus, the policy of the held |
| 3826 |
priority was specified in order to avoid surprises (especially when using |
| 3827 |
the EDF policy).]} |
| 3828 |
@end{DiffWord95} |
| 3829 |
|
| 3830 |
|
| 3831 |
@LabeledClause{Other Optimizations and Determinism Rules} |
| 3832 |
|
| 3833 |
@begin{Intro} |
| 3834 |
@Redundant[This clause describes various requirements for |
| 3835 |
improving the response and determinism in a real-time system.] |
| 3836 |
@end{Intro} |
| 3837 |
|
| 3838 |
@begin{ImplReq} |
| 3839 |
|
| 3840 |
If the implementation blocks interrupts (see @RefSecNum{Interrupt Support}) not |
| 3841 |
as a result of direct user |
| 3842 |
action (e.g. an execution of a protected action) there shall be an upper |
| 3843 |
bound on the duration of this blocking. |
| 3844 |
@begin{Ramification} |
| 3845 |
The implementation shall not allow itself to be interrupted when it is in a |
| 3846 |
state where it is unable to support all the language-defined operations |
| 3847 |
permitted in the execution of interrupt handlers. |
| 3848 |
(see @RefSecNum{Protected Subprograms and Protected Actions}). |
| 3849 |
@end{Ramification} |
| 3850 |
|
| 3851 |
The implementation shall recognize entry-less protected types. |
| 3852 |
The overhead of acquiring the execution resource of an object of such a type |
| 3853 |
(see @RefSecNum{Protected Subprograms and Protected Actions}) shall be |
| 3854 |
minimized. In particular, there should not be any overhead due to evaluating |
| 3855 |
@nt{entry_barrier} @nt{condition}s. |
| 3856 |
@begin{ImplNote} |
| 3857 |
Ideally the overhead should just be a spin-lock. |
| 3858 |
@end{ImplNote} |
| 3859 |
|
| 3860 |
Unchecked_Deallocation shall be supported for terminated tasks that are |
| 3861 |
designated by access types, and shall have the effect of releasing all |
| 3862 |
the storage associated with the task. This includes any run-time system |
| 3863 |
or heap storage that has been implicitly allocated for the task by the |
| 3864 |
implementation. |
| 3865 |
|
| 3866 |
@end{ImplReq} |
| 3867 |
|
| 3868 |
@begin{DocReq} |
| 3869 |
|
| 3870 |
The implementation shall document the |
| 3871 |
upper bound on the duration of interrupt blocking caused by the |
| 3872 |
implementation. If this is different for different interrupts or |
| 3873 |
interrupt priority levels, it should be documented for each case. |
| 3874 |
@ChgImplDef{Version=[2],Kind=[Deleted],Text=[@ChgDeleted{Version=[2], |
| 3875 |
Text=[The upper bound on the duration of interrupt blocking caused by |
| 3876 |
the implementation.]}]} |
| 3877 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3878 |
Text=[The upper bound on the duration of interrupt blocking caused by |
| 3879 |
the implementation.]}]} |
| 3880 |
|
| 3881 |
@end{DocReq} |
| 3882 |
|
| 3883 |
@begin{Metrics} |
| 3884 |
@Leading@;The implementation shall document the following metric: |
| 3885 |
@begin{Itemize} |
| 3886 |
The overhead associated with obtaining |
| 3887 |
a mutual-exclusive access to an entry-less protected object. This shall be |
| 3888 |
measured in the following way: |
| 3889 |
|
| 3890 |
@NoPrefix@Leading@keepnext@;For a protected object of the form: |
| 3891 |
@begin{example} |
| 3892 |
@key{protected} Lock @key{is} |
| 3893 |
@key{procedure} Set; |
| 3894 |
@Key{function} Read @Key{return} Boolean; |
| 3895 |
@key{private} |
| 3896 |
Flag : Boolean := False; |
| 3897 |
@key{end} Lock; |
| 3898 |
|
| 3899 |
@key{protected body} Lock @key{is} |
| 3900 |
@key{procedure} Set @key{is} |
| 3901 |
@key{begin} |
| 3902 |
Flag := True; |
| 3903 |
@key{end} Set; |
| 3904 |
@Key{function} Read @Key{return} Boolean |
| 3905 |
@key{Begin} |
| 3906 |
@key{return} Flag; |
| 3907 |
@key{end} Read; |
| 3908 |
@key{end} Lock; |
| 3909 |
@end{example} |
| 3910 |
|
| 3911 |
@NoPrefix@;The execution time, in processor clock cycles, of a call to |
| 3912 |
Set. This shall be measured between the point just before |
| 3913 |
issuing the call, and the point just after the call |
| 3914 |
completes. |
| 3915 |
The function Read shall be called later to verify that Set was indeed |
| 3916 |
called (and not optimized away). The |
| 3917 |
calling task shall have |
| 3918 |
sufficiently high priority as to not be preempted during the measurement |
| 3919 |
period. The protected object shall have sufficiently high ceiling priority |
| 3920 |
to allow the task to call Set. |
| 3921 |
|
| 3922 |
@NoPrefix@;For a multiprocessor, if supported, the metric shall be reported for the |
| 3923 |
case where no contention (on the execution resource) exists |
| 3924 |
@Redundant[from tasks executing on other processors]. |
| 3925 |
@end{Itemize} |
| 3926 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 3927 |
Text=[The metrics for entry-less protected objects.]}]} |
| 3928 |
@end{Metrics} |
| 3929 |
|
| 3930 |
|
| 3931 |
@LabeledAddedClause{Version=[2],Name=[Run-time Profiles]} |
| 3932 |
|
| 3933 |
@begin{Intro} |
| 3934 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3935 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause |
| 3936 |
specifies a mechanism for defining run-time profiles.]]} |
| 3937 |
@end{Intro} |
| 3938 |
|
| 3939 |
@begin{Syntax} |
| 3940 |
@begin{SyntaxText} |
| 3941 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3942 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The form of a |
| 3943 |
@nt{pragma} Profile is as follows:]} |
| 3944 |
@end{SyntaxText} |
| 3945 |
|
| 3946 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3947 |
@ChgAdded{Version=[2],Text=`@AddedPragmaSyn`Version=[2],@key{pragma} @prag<Profile> (@SynI{profile_}@Syn2{identifier} {, @SynI{profile_}@Syn2{pragma_argument_association}});''} |
| 3948 |
|
| 3949 |
@end{Syntax} |
| 3950 |
|
| 3951 |
@begin{Legality} |
| 3952 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3953 |
@ChgAdded{Version=[2],Text=[The @SynI{profile_}@nt{identifier} shall be the name |
| 3954 |
of a run-time profile. The semantics of any |
| 3955 |
@SynI{profile_}@nt{pragma_@!argument_@!association}s are defined by |
| 3956 |
the run-time profile specified by the @SynI{profile_}@nt{identifier}.]} |
| 3957 |
@end{Legality} |
| 3958 |
|
| 3959 |
@begin{StaticSem} |
| 3960 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3961 |
@ChgAdded{Version=[2],Text=[ |
| 3962 |
A profile is equivalent to the set of configuration pragmas that is |
| 3963 |
defined for each run-time profile.]} |
| 3964 |
@end{StaticSem} |
| 3965 |
|
| 3966 |
@begin{Linktime} |
| 3967 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3968 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=[configuration pragma], Sec=(Profile)} |
| 3969 |
@PDefn2{Term=[pragma, configuration], Sec=(Profile)} |
| 3970 |
A @nt{pragma} Profile is a configuration pragma. |
| 3971 |
There may be more than one @nt{pragma} Profile for a partition.]} |
| 3972 |
@end{Linktime} |
| 3973 |
|
| 3974 |
@begin{Extend95} |
| 3975 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3976 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 3977 |
@nt{Pragma} Profile is new.]} |
| 3978 |
@end{Extend95} |
| 3979 |
|
| 3980 |
|
| 3981 |
@RMNewPage |
| 3982 |
@LabeledAddedSubClause{Version=[2],Name=[The Ravenscar Profile]} |
| 3983 |
|
| 3984 |
@begin{Intro} |
| 3985 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3986 |
@ChgAdded{Version=[2],Text=[@Redundant[This clause |
| 3987 |
defines the Ravenscar profile.]@Defn{Ravenscar}]} |
| 3988 |
@end{Intro} |
| 3989 |
|
| 3990 |
@begin{Legality} |
| 3991 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 3992 |
@ChgAdded{Version=[2],Text=[The @SynI{profile_}@nt{identifier} |
| 3993 |
Ravenscar is a run-time profile. |
| 3994 |
For run-time profile Ravenscar, there shall be no |
| 3995 |
@Syni{profile_}@nt{pragma_argument_association}s.]} |
| 3996 |
@end{Legality} |
| 3997 |
|
| 3998 |
@begin{StaticSem} |
| 3999 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 4000 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The run-time profile |
| 4001 |
Ravenscar is equivalent to the following set of pragmas:]} |
| 4002 |
|
| 4003 |
@begin{Example} |
| 4004 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01],ARef=[AI95-00297-01],ARef=[AI95-00394-01]} |
| 4005 |
@ChgAdded{Version=[2],Text=[ |
| 4006 |
@key{pragma} Task_Dispatching_Policy (FIFO_Within_Priorities); |
| 4007 |
@key{pragma} Locking_Policy (Ceiling_Locking); |
| 4008 |
@key{pragma} Detect_Blocking; |
| 4009 |
@key{pragma} Restrictions ( |
| 4010 |
No_Abort_Statements, |
| 4011 |
No_Dynamic_Attachment, |
| 4012 |
No_Dynamic_Priorities, |
| 4013 |
No_Implicit_Heap_Allocations, |
| 4014 |
No_Local_Protected_Objects, |
| 4015 |
No_Local_Timing_Events, |
| 4016 |
No_Protected_Type_Allocators, |
| 4017 |
No_Relative_Delay, |
| 4018 |
No_Requeue_Statements, |
| 4019 |
No_Select_Statements, |
| 4020 |
No_Specific_Termination_Handlers, |
| 4021 |
No_Task_Allocators, |
| 4022 |
No_Task_Hierarchy, |
| 4023 |
No_Task_Termination, |
| 4024 |
Simple_Barriers, |
| 4025 |
Max_Entry_Queue_Length => 1, |
| 4026 |
Max_Protected_Entries => 1, |
| 4027 |
Max_Task_Entries => 0, |
| 4028 |
No_Dependence => Ada.Asynchronous_Task_Control, |
| 4029 |
No_Dependence => Ada.Calendar, |
| 4030 |
No_Dependence => Ada.Execution_Time.Group_Budget, |
| 4031 |
No_Dependence => Ada.Execution_Time.Timers, |
| 4032 |
No_Dependence => Ada.Task_Attributes);]} |
| 4033 |
@end{Example} |
| 4034 |
|
| 4035 |
@begin{Discussion} |
| 4036 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4037 |
@ChgAdded{Version=[2],Text=[The Ravenscar profile is named for the location |
| 4038 |
of the meeting that defined its initial version. The name is now in widespread |
| 4039 |
use, so we stick with existing practice, rather than using a more descriptive |
| 4040 |
name.@Comment{ This is another example of Ada's lousy marketing sense; casual |
| 4041 |
readers, especially those outside of Ada, have no conception of what |
| 4042 |
@lquotes@;Ravenscar@rquotes@; is, and thus are much less likely to investigate |
| 4043 |
it to find out how it can help them.}]} |
| 4044 |
@end{Discussion} |
| 4045 |
|
| 4046 |
@end{StaticSem} |
| 4047 |
|
| 4048 |
@begin{Notes} |
| 4049 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]} |
| 4050 |
@ChgAdded{Version=[2],Text=[ |
| 4051 |
The effect of the Max_Entry_Queue_Length => 1 restriction applies |
| 4052 |
only to protected entry queues due to the accompanying restriction of |
| 4053 |
Max_Task_Entries => 0.]} |
| 4054 |
@end{Notes} |
| 4055 |
|
| 4056 |
@begin{Extend95} |
| 4057 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]} |
| 4058 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 4059 |
The Ravenscar profile is new.]} |
| 4060 |
@end{Extend95} |
| 4061 |
|
| 4062 |
|
| 4063 |
@RMNewPage@Comment{For printed Ada 2007 RM} |
| 4064 |
@LabeledAddedClause{Version=[2],Name=[Execution Time]} |
| 4065 |
|
| 4066 |
@begin{Intro} |
| 4067 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4068 |
@ChgAdded{Version=[2],Text=[This clause describes a language-defined package to |
| 4069 |
measure execution time.]} |
| 4070 |
@end{Intro} |
| 4071 |
|
| 4072 |
@begin{StaticSem} |
| 4073 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4074 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 4075 |
language-defined library package exists:]} |
| 4076 |
@begin{Example} |
| 4077 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4078 |
@ChgAdded{Version=[2],Text=[@key{with} Ada.Task_Identification; |
| 4079 |
@key{with} Ada.Real_Time; @key{use} Ada.Real_Time; |
| 4080 |
@key{package} Ada.Execution_Time @key{is}@ChildUnit{Parent=[Ada],Child=[Execution_Time]}]} |
| 4081 |
|
| 4082 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4083 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{CPU_Time} @key{is private}; |
| 4084 |
@AdaObjDefn{CPU_Time_First} : @key{constant} CPU_Time; |
| 4085 |
@AdaObjDefn{CPU_Time_Last} : @key{constant} CPU_Time; |
| 4086 |
@AdaObjDefn{CPU_Time_Unit} : @key{constant} := @RI{implementation-defined-real-number}; |
| 4087 |
@AdaObjDefn{CPU_Tick} : @key{constant} Time_Span;]} |
| 4088 |
|
| 4089 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4090 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Clock} |
| 4091 |
(T : Ada.Task_Identification.Task_Id |
| 4092 |
:= Ada.Task_Identification.Current_Task) |
| 4093 |
@key{return} CPU_Time;]} |
| 4094 |
|
| 4095 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4096 |
@ChgAdded{Version=[2],Text=[ @key{function} "+" (Left : CPU_Time; Right : Time_Span) @key{return} CPU_Time; |
| 4097 |
@key{function} "+" (Left : Time_Span; Right : CPU_Time) @key{return} CPU_Time; |
| 4098 |
@key{function} "-" (Left : CPU_Time; Right : Time_Span) @key{return} CPU_Time; |
| 4099 |
@key{function} "-" (Left : CPU_Time; Right : CPU_Time) @key{return} Time_Span;]} |
| 4100 |
|
| 4101 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4102 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : CPU_Time) @key{return} Boolean; |
| 4103 |
@key{function} "<=" (Left, Right : CPU_Time) @key{return} Boolean; |
| 4104 |
@key{function} ">" (Left, Right : CPU_Time) @key{return} Boolean; |
| 4105 |
@key{function} ">=" (Left, Right : CPU_Time) @key{return} Boolean;]} |
| 4106 |
|
| 4107 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4108 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Split} |
| 4109 |
(T : @key{in} CPU_Time; SC : @key{out} Seconds_Count; TS : @key{out} Time_Span);]} |
| 4110 |
|
| 4111 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4112 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Of} (SC : Seconds_Count; |
| 4113 |
TS : Time_Span := Time_Span_Zero) @key{return} CPU_Time;]} |
| 4114 |
|
| 4115 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4116 |
@ChgAdded{Version=[2],Text=[@key{private} |
| 4117 |
... -- @RI[not specified by the language] |
| 4118 |
@key{end} Ada.Execution_Time;]} |
| 4119 |
|
| 4120 |
@end{Example} |
| 4121 |
|
| 4122 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4123 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[execution time],Sec=[of a task]} |
| 4124 |
@Defn2{Term=[CPU time],Sec=[of a task]} |
| 4125 |
The @i<execution time> or CPU time of a given task is defined as the time spent by |
| 4126 |
the system executing that task, including the time spent executing run-time or |
| 4127 |
system services on its behalf. The mechanism used to measure execution time is |
| 4128 |
implementation defined. It is implementation defined which task, if any, is |
| 4129 |
charged the execution time that is consumed by interrupt handlers and run-time |
| 4130 |
services on behalf of the system.]} |
| 4131 |
@begin{Discussion} |
| 4132 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4133 |
@ChgAdded{Version=[2],Text=[The implementation-defined properties above |
| 4134 |
and of the values declared in the package are repeated in @DocReqTitle, |
| 4135 |
so we don't mark them as implementation-defined.]} |
| 4136 |
@end{Discussion} |
| 4137 |
|
| 4138 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4139 |
@ChgAdded{Version=[2],Text=[The type CPU_Time represents the execution time of |
| 4140 |
a task. The set of values of this type corresponds one-to-one with an |
| 4141 |
implementation-defined range of mathematical integers.]} |
| 4142 |
|
| 4143 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4144 |
@ChgAdded{Version=[2],Text=[The CPU_Time value I represents the half-open |
| 4145 |
execution-time interval that starts with I*CPU_Time_Unit and is limited by |
| 4146 |
(I+1)*CPU_Time_Unit, where CPU_Time_Unit is an implementation-defined |
| 4147 |
real number. For each task, the execution time value is set to zero at |
| 4148 |
the creation of the task.]} |
| 4149 |
|
| 4150 |
@begin{Ramification} |
| 4151 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4152 |
@ChgAdded{Version=[2],Text=[Since it is implementation-defined which task |
| 4153 |
is charged execution time for system services, the execution time value |
| 4154 |
may become non-zero even before the start of the activation of the task.]} |
| 4155 |
@end{Ramification} |
| 4156 |
|
| 4157 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4158 |
@ChgAdded{Version=[2],Text=[CPU_Time_First and CPU_Time_Last are the smallest |
| 4159 |
and largest values of the CPU_Time type, respectively.]} |
| 4160 |
@end{StaticSem} |
| 4161 |
|
| 4162 |
@begin{RunTime} |
| 4163 |
|
| 4164 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4165 |
@ChgAdded{Version=[2],Text=[@Defn{CPU clock tick} |
| 4166 |
CPU_Time_Unit is the smallest amount of execution time representable |
| 4167 |
by the CPU_Time type; it is expressed in seconds. A @i<CPU clock tick> is an |
| 4168 |
execution time interval during which the clock value (as observed by |
| 4169 |
calling the Clock function) remains constant. CPU_Tick is the average |
| 4170 |
length of such intervals.]} |
| 4171 |
|
| 4172 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4173 |
@ChgAdded{Version=[2],Text=[The effects of the operators on CPU_Time and |
| 4174 |
Time_Span are as for the operators defined for integer types.]} |
| 4175 |
|
| 4176 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4177 |
@ChgAdded{Version=[2],Text=[The function Clock returns the current execution |
| 4178 |
time of the task identified by T; Tasking_Error is raised if that task has |
| 4179 |
terminated; Program_Error is raised if the value of T is |
| 4180 |
Task_Identification.Null_Task_Id.]} |
| 4181 |
|
| 4182 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4183 |
@ChgAdded{Version=[2],Text=[The effects of the Split and Time_Of operations are defined as |
| 4184 |
follows, treating values of type CPU_Time, Time_Span, and |
| 4185 |
Seconds_Count as mathematical integers. The effect of Split (T, SC, |
| 4186 |
TS) is to set SC and TS to values such that T*CPU_Time_Unit = SC*1.0 + |
| 4187 |
TS*CPU_Time_Unit, and 0.0 <= TS*CPU_Time_Unit < 1.0. The value |
| 4188 |
returned by Time_Of(SC,TS) is the execution-time value T such that |
| 4189 |
T*CPU_Time_Unit=SC*1.0 + TS*CPU_Time_Unit.]} |
| 4190 |
|
| 4191 |
@end{RunTime} |
| 4192 |
|
| 4193 |
@begin{Erron} |
| 4194 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4195 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 4196 |
For a call of Clock, if the task identified by T no longer exists, the |
| 4197 |
execution of the program is erroneous.]} |
| 4198 |
@end{Erron} |
| 4199 |
|
| 4200 |
@begin{ImplReq} |
| 4201 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4202 |
@ChgAdded{Version=[2],Text=[The range of CPU_Time values shall be sufficient |
| 4203 |
to uniquely represent the range of execution times from the task start-up to 50 |
| 4204 |
years of execution time later. CPU_Tick shall be no greater than 1 |
| 4205 |
millisecond.]} |
| 4206 |
@end{ImplReq} |
| 4207 |
|
| 4208 |
@begin{DocReq} |
| 4209 |
|
| 4210 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4211 |
@ChgAdded{Version=[2],Text=[The implementation shall document the values of |
| 4212 |
CPU_Time_First, CPU_Time_Last, CPU_Time_Unit, and CPU_Tick.]} |
| 4213 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4214 |
Text=[The values of CPU_Time_First, CPU_Time_Last, CPU_Time_Unit, and CPU_Tick |
| 4215 |
of package Execution_Time.]}]} |
| 4216 |
|
| 4217 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4218 |
@ChgAdded{Version=[2],Text=[The implementation shall document the properties of |
| 4219 |
the underlying mechanism used to measure execution times, such as the range of |
| 4220 |
values supported and any relevant aspects of the underlying hardware or |
| 4221 |
operating system facilities used.]} |
| 4222 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4223 |
Text=[The properties of the mechanism used to implement package Execution_Time.]}]} |
| 4224 |
|
| 4225 |
@end{DocReq} |
| 4226 |
|
| 4227 |
@begin{Metrics} |
| 4228 |
|
| 4229 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4230 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The implementation |
| 4231 |
shall document the following metrics:]} |
| 4232 |
|
| 4233 |
@begin{Itemize} |
| 4234 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4235 |
@ChgAdded{Version=[2],Text={An upper bound on the execution-time duration of a |
| 4236 |
clock tick. This is a value D such that if t1 and t2 are any execution times of |
| 4237 |
a given task such that t1 < t2 and Clock@-{t1} = Clock@-{t2} then |
| 4238 |
t2 @en@; t1 <= D.}} |
| 4239 |
|
| 4240 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4241 |
@ChgAdded{Version=[2],Text=[An upper bound on the size of a clock jump. A clock |
| 4242 |
jump is the difference between two successive distinct values of an |
| 4243 |
execution-time clock (as observed by calling the Clock function with the same |
| 4244 |
Task_Id).]} |
| 4245 |
|
| 4246 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4247 |
@ChgAdded{Version=[2],Text=[An upper bound on the execution time of a call to |
| 4248 |
the Clock function, in processor clock cycles.]} |
| 4249 |
|
| 4250 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4251 |
@ChgAdded{Version=[2],Text=[Upper bounds on the execution times of the |
| 4252 |
operators of the type CPU_Time, in processor clock cycles.]} |
| 4253 |
@end{Itemize} |
| 4254 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4255 |
Text=[The metrics for execution time.]}]} |
| 4256 |
|
| 4257 |
@end{Metrics} |
| 4258 |
|
| 4259 |
@begin{ImplPerm} |
| 4260 |
|
| 4261 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4262 |
@ChgAdded{Version=[2],Text=[Implementations targeted to machines with word size |
| 4263 |
smaller than 32 bits need not support the full range and granularity of the |
| 4264 |
CPU_Time type.]} |
| 4265 |
|
| 4266 |
@end{ImplPerm} |
| 4267 |
|
| 4268 |
@begin{ImplAdvice} |
| 4269 |
|
| 4270 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4271 |
@ChgAdded{Version=[2],Text=[When appropriate, implementations should provide |
| 4272 |
configuration mechanisms to change the value of CPU_Tick.]} |
| 4273 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4274 |
Text=[When appropriate, implementations should provide |
| 4275 |
configuration mechanisms to change the value of Execution_Time.CPU_Tick.]}]} |
| 4276 |
|
| 4277 |
@end{ImplAdvice} |
| 4278 |
|
| 4279 |
@begin{Extend95} |
| 4280 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4281 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 4282 |
The package Execution_Time is new.]} |
| 4283 |
@end{Extend95} |
| 4284 |
|
| 4285 |
|
| 4286 |
@LabeledAddedSubclause{Version=[2],Name=[Execution Time Timers]} |
| 4287 |
|
| 4288 |
@begin{Intro} |
| 4289 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4290 |
@ChgAdded{Version=[2],Text=[This clause describes a language-defined package |
| 4291 |
that provides a facility for calling a handler when a task has used a defined |
| 4292 |
amount of CPU time.]} |
| 4293 |
@end{Intro} |
| 4294 |
|
| 4295 |
@begin{StaticSem} |
| 4296 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4297 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 4298 |
language-defined library package exists:]} |
| 4299 |
@begin{Example} |
| 4300 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4301 |
@ChgAdded{Version=[2],Text=[@key{with} System; |
| 4302 |
@key{package} Ada.Execution_Time.Timers @key{is}@ChildUnit{Parent=[Ada.Execution_Time],Child=[Timers]}]} |
| 4303 |
|
| 4304 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4305 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timer} (T : @key{not null access constant} |
| 4306 |
Ada.Task_Identification.Task_Id) @key{is} |
| 4307 |
@key{tagged limited private};]} |
| 4308 |
|
| 4309 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4310 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timer_Handler} @key{is} |
| 4311 |
@key{access protected procedure} (TM : @key{in out} Timer);]} |
| 4312 |
|
| 4313 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4314 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Min_Handler_Ceiling} : @key{constant} System.Any_Priority := |
| 4315 |
@RI[implementation-defined];]} |
| 4316 |
|
| 4317 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4318 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (TM : @key{in out} Timer; |
| 4319 |
In_Time : @key{in} Time_Span; |
| 4320 |
Handler : @key{in} Timer_Handler); |
| 4321 |
@key{procedure} @AdaSubDefn{Set_Handler} (TM : @key{in out} Timer; |
| 4322 |
At_Time : @key{in} CPU_Time; |
| 4323 |
Handler : @key{in} Timer_Handler); |
| 4324 |
@key{function} @AdaSubDefn{Current_Handler} (TM : Timer) @key{return} Timer_Handler; |
| 4325 |
@key{procedure} @AdaSubDefn{Cancel_Handler} (TM : @key{in out} Timer; |
| 4326 |
Cancelled : @key{out} Boolean);]} |
| 4327 |
|
| 4328 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4329 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Remaining} (TM : Timer) @key{return} Time_Span;]} |
| 4330 |
|
| 4331 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4332 |
@ChgAdded{Version=[2],Text=[ @AdaExcDefn{Timer_Resource_Error} : @key{exception};]} |
| 4333 |
|
| 4334 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4335 |
@ChgAdded{Version=[2],Text=[@key{private} |
| 4336 |
... -- not specified by the language |
| 4337 |
@key{end} Ada.Execution_Time.Timers;]} |
| 4338 |
|
| 4339 |
@end{Example} |
| 4340 |
|
| 4341 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4342 |
@ChgAdded{Version=[2],Text=[The type Timer represents an execution-time event |
| 4343 |
for a single task and is capable of detecting execution-time overruns. The |
| 4344 |
access discriminant T identifies the task concerned. The type Timer needs |
| 4345 |
finalization (see @RefSecNum{User-Defined Assignment and Finalization}).]} |
| 4346 |
|
| 4347 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4348 |
@ChgAdded{Version=[2],Text=[An object of type Timer is said to be @i<set> if it |
| 4349 |
is associated with a non-null value of type Timer_Handler and @i<cleared> |
| 4350 |
otherwise. All Timer objects are initially cleared. |
| 4351 |
@PDefn2{Term=[set],Sec=[execution timer object]} |
| 4352 |
@PDefn2{Term=[clear],Sec=[execution timer object]}]} |
| 4353 |
|
| 4354 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4355 |
@ChgAdded{Version=[2],Text=[The type Timer_Handler identifies a protected |
| 4356 |
procedure to be executed by the implementation when the timer expires. Such a |
| 4357 |
protected procedure is called a @i<handler>. |
| 4358 |
@PDefn2{Term=[handler],Sec=[execution timer]}]} |
| 4359 |
|
| 4360 |
@begin{Discussion} |
| 4361 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4362 |
@ChgAdded{Version=[2],Text=[Type Timer is tagged. This makes it possible to |
| 4363 |
share a handler between several events. In simple cases, 'Access can be used |
| 4364 |
to compare the parameter with a specific timer object (this works because a |
| 4365 |
tagged type is a by-reference type). In more complex cases, a type extension |
| 4366 |
of type Timer can be declared; a double type conversion can be used to access |
| 4367 |
the extension data. An example of how this can be done can be found for the |
| 4368 |
similar type Timing_Event, see @RefSecNum{Timing Events}.]} |
| 4369 |
@end{Discussion} |
| 4370 |
|
| 4371 |
@end{StaticSem} |
| 4372 |
|
| 4373 |
@begin{Runtime} |
| 4374 |
|
| 4375 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4376 |
@ChgAdded{Version=[2],Text=[When a Timer object is created, or upon the first |
| 4377 |
call of a Set_Handler procedure with the timer as parameter, the resources |
| 4378 |
required to operate an execution-time timer based on the associated |
| 4379 |
execution-time clock are allocated and initialized. If this operation would |
| 4380 |
exceed the available resources, Timer_Resource_Error is raised.]} |
| 4381 |
|
| 4382 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4383 |
@ChgAdded{Version=[2],Text=[The procedures Set_Handler associate the handler |
| 4384 |
Handler with the timer TM; if Handler is @key[null], the timer is cleared, |
| 4385 |
otherwise it is set. The first procedure Set_Handler loads the timer TM with an |
| 4386 |
interval specified by the Time_Span parameter. In this mode, the timer TM |
| 4387 |
@i<expires> when the execution time of the task identified by TM.T.@key[all] |
| 4388 |
has increased by In_Time; if In_Time is less than or equal to zero, the timer |
| 4389 |
expires immediately. The second procedure Set_Handler loads the timer TM with |
| 4390 |
the absolute value specified by At_Time. In this mode, the timer TM expires |
| 4391 |
when the execution time of the task identified by TM.T.@key[all] reaches |
| 4392 |
At_Time; if the value of At_Time has already been reached when Set_Handler is |
| 4393 |
called, the timer expires immediately.@Defn2{Term=[expires], |
| 4394 |
Sec=[execution timer]}]} |
| 4395 |
|
| 4396 |
@begin{ImplNote} |
| 4397 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4398 |
@ChgAdded{Version=[2],Text=[Since an access-to-constant can designate a |
| 4399 |
variable, the Task_Id value designated by the discriminant of a Timer |
| 4400 |
object can be changed after the object is created. Thus, an implementation |
| 4401 |
cannot use the value of the Task_Id other than where this Standard specifies. |
| 4402 |
For instance, the Task_Id should be read when the timer is set, but it |
| 4403 |
should not be used when the timer expires (as it may designate a different |
| 4404 |
task at that point.]} |
| 4405 |
@end{ImplNote} |
| 4406 |
|
| 4407 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4408 |
@ChgAdded{Version=[2],Text=[A call of a procedure Set_Handler for a timer that |
| 4409 |
is already set replaces the handler and the (absolute or relative) execution |
| 4410 |
time; if Handler is not @b<null>, the timer remains set.]} |
| 4411 |
|
| 4412 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4413 |
@ChgAdded{Version=[2],Text=[When a timer expires, the associated handler is |
| 4414 |
executed, passing the timer as parameter. The initial action of the execution |
| 4415 |
of the handler is to clear the event.]} |
| 4416 |
|
| 4417 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4418 |
@ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler |
| 4419 |
associated with the timer TM if that timer is set; otherwise it returns |
| 4420 |
@b<null>.]} |
| 4421 |
|
| 4422 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4423 |
@ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the timer if it |
| 4424 |
is set. Cancelled is assigned True if the timer was set prior to it being |
| 4425 |
cleared; otherwise it is assigned False.]} |
| 4426 |
|
| 4427 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4428 |
@ChgAdded{Version=[2],Text=[The function Time_Remaining returns the execution |
| 4429 |
time interval that remains until the timer TM would expire, if that timer is |
| 4430 |
set; otherwise it returns Time_Span_Zero.]} |
| 4431 |
|
| 4432 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4433 |
@ChgAdded{Version=[2],Text=[The constant Min_Handler_Ceiling is the |
| 4434 |
minimum ceiling priority required for a protected object with a handler to |
| 4435 |
ensure that no ceiling violation will occur when that handler is invoked.]} |
| 4436 |
|
| 4437 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4438 |
@ChgAdded{Version=[2],Text=[As part of the finalization of an object of type |
| 4439 |
Timer, the timer is cleared.]} |
| 4440 |
|
| 4441 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4442 |
@ChgAdded{Version=[2],Text=[For all the subprograms defined in this package, |
| 4443 |
Tasking_Error is raised if the task identified by TM.T.@key[all] has terminated, and |
| 4444 |
Program_Error is raised if the value of TM.T.@key[all] is |
| 4445 |
Task_Identification.Null_Task_Id.]} |
| 4446 |
|
| 4447 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4448 |
@ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked as |
| 4449 |
part of the expiration of a timer has no effect.]} |
| 4450 |
|
| 4451 |
@end{Runtime} |
| 4452 |
|
| 4453 |
@begin{Erron} |
| 4454 |
|
| 4455 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4456 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 4457 |
For a call of any of the subprograms defined in this package, if the task |
| 4458 |
identified by TM.T.@key[all] no longer exists, the execution of the program is |
| 4459 |
erroneous.]} |
| 4460 |
|
| 4461 |
@end{Erron} |
| 4462 |
|
| 4463 |
@begin{ImplReq} |
| 4464 |
|
| 4465 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4466 |
@ChgAdded{Version=[2],Text=[For a given Timer object, the implementation shall |
| 4467 |
perform the operations declared in this package atomically with respect to any |
| 4468 |
of these operations on the same Timer object. The replacement of a handler by a |
| 4469 |
call of Set_Handler shall be performed atomically with respect to the execution |
| 4470 |
of the handler.]} |
| 4471 |
|
| 4472 |
@begin{Reason} |
| 4473 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4474 |
@ChgAdded{Version=[2],Text=[This prevents various race conditions. In |
| 4475 |
particular it ensures that if an event occurs when Set_Handler is changing |
| 4476 |
the handler then either the new or old handler is executed in response to the |
| 4477 |
appropriate event. It is never possible for a new handler to be executed in |
| 4478 |
response to an old event]} |
| 4479 |
@end{Reason} |
| 4480 |
|
| 4481 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4482 |
@ChgAdded{Version=[2],Text=[When an object of type Timer is finalized, the |
| 4483 |
system resources used by the timer shall be deallocated.]} |
| 4484 |
|
| 4485 |
@end{ImplReq} |
| 4486 |
|
| 4487 |
@begin{ImplPerm} |
| 4488 |
|
| 4489 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4490 |
@ChgAdded{Version=[2],Text=[Implementations may limit the number of timers that |
| 4491 |
can be defined for each task. If this limit is exceeded then |
| 4492 |
Timer_Resource_Error is raised.]} |
| 4493 |
|
| 4494 |
@end{ImplPerm} |
| 4495 |
|
| 4496 |
@begin{Notes} |
| 4497 |
|
| 4498 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4499 |
@ChgAdded{Version=[2],Text=[A Timer_Handler can be associated with several |
| 4500 |
Timer objects.]} |
| 4501 |
|
| 4502 |
@end{Notes} |
| 4503 |
|
| 4504 |
@begin{Extend95} |
| 4505 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]} |
| 4506 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 4507 |
The package Execution_Time.Timers is new.]} |
| 4508 |
@end{Extend95} |
| 4509 |
|
| 4510 |
|
| 4511 |
@RMNewPage@Comment{For printed Ada 2007 RM} |
| 4512 |
@LabeledAddedSubclause{Version=[2],Name=[Group Execution Time Budgets]} |
| 4513 |
|
| 4514 |
@begin{Intro} |
| 4515 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4516 |
@ChgAdded{Version=[2],Text=[This clause describes a language-defined package to |
| 4517 |
assign execution time budgets to groups of tasks.]} |
| 4518 |
@end{Intro} |
| 4519 |
|
| 4520 |
@begin{StaticSem} |
| 4521 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4522 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 4523 |
language-defined library package exists:]} |
| 4524 |
@begin{Example} |
| 4525 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4526 |
@ChgAdded{Version=[2],Text=[@key{with} System; |
| 4527 |
@key{package} Ada.Execution_Time.Group_Budgets @key{is}@ChildUnit{Parent=[Ada.Execution_Time],Child=[Group_Budgets]}]} |
| 4528 |
|
| 4529 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4530 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Group_Budget} @key{is tagged limited private};]} |
| 4531 |
|
| 4532 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4533 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Group_Budget_Handler} @key{is access} |
| 4534 |
@key{protected procedure} (GB : @key{in out} Group_Budget);]} |
| 4535 |
|
| 4536 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4537 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Task_Array} @key{is array} (Positive @key{range} <>) @key{of} |
| 4538 |
Ada.Task_Identification.Task_Id;]} |
| 4539 |
|
| 4540 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4541 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Min_Handler_Ceiling} : @key{constant} System.Any_Priority := |
| 4542 |
@RI[implementation-defined];]} |
| 4543 |
|
| 4544 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4545 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Add_Task} (GB : @key{in out} Group_Budget; |
| 4546 |
T : @key{in} Ada.Task_Identification.Task_Id); |
| 4547 |
@key{procedure} @AdaSubDefn{Remove_Task} (GB: @key{in out} Group_Budget; |
| 4548 |
T : @key{in} Ada.Task_Identification.Task_Id); |
| 4549 |
@key{function} @AdaSubDefn{Is_Member} (GB : Group_Budget; |
| 4550 |
T : Ada.Task_Identification.Task_Id) @key{return} Boolean; |
| 4551 |
@key{function} @AdaSubDefn{Is_A_Group_Member} |
| 4552 |
(T : Ada.Task_Identification.Task_Id) @key{return} Boolean; |
| 4553 |
@key{function} @AdaSubDefn{Members} (GB : Group_Budget) @key{return} Task_Array;]} |
| 4554 |
|
| 4555 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4556 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replenish} (GB : @key{in out} Group_Budget; To : @key{in} Time_Span); |
| 4557 |
@key{procedure} @AdaSubDefn{Add} (GB : @key{in out} Group_Budget; Interval : @key{in} Time_Span); |
| 4558 |
@key{function} @AdaSubDefn{Budget_Has_Expired} (GB : Group_Budget) @key{return} Boolean; |
| 4559 |
@key{function} @AdaSubDefn{Budget_Remaining} (GB : Group_Budget) @key{return} Time_Span;]} |
| 4560 |
|
| 4561 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4562 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (GB : @key{in out} Group_Budget; |
| 4563 |
Handler : @key{in} Group_Budget_Handler); |
| 4564 |
@key{function} @AdaSubDefn{Current_Handler} (GB : Group_Budget) |
| 4565 |
@key{return} Group_Budget_Handler; |
| 4566 |
@key{procedure} @AdaSubDefn{Cancel_Handler} (GB : @key{in out} Group_Budget; |
| 4567 |
Cancelled : @key{out} Boolean);]} |
| 4568 |
|
| 4569 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4570 |
@ChgAdded{Version=[2],Text=[ @AdaExcDefn{Group_Budget_Error} : @key{exception};]} |
| 4571 |
|
| 4572 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4573 |
@ChgAdded{Version=[2],Text=[@key{private} |
| 4574 |
-- not specified by the language |
| 4575 |
@key{end} Ada.Execution_Time.Group_Budgets;]} |
| 4576 |
|
| 4577 |
@end{Example} |
| 4578 |
|
| 4579 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4580 |
@ChgAdded{Version=[2],Text=[The type Group_Budget represents an execution time |
| 4581 |
budget to be used by a group of tasks. The type Group_Budget needs finalization |
| 4582 |
(see @RefSecNum{User-Defined Assignment and Finalization}). A task can belong |
| 4583 |
to at most one group. Tasks of any priority can be added to a group.]} |
| 4584 |
|
| 4585 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4586 |
@ChgAdded{Version=[2],Text=[An object of type Group_Budget has an associated |
| 4587 |
nonnegative value of type Time_Span known as its @i<budget>, which is |
| 4588 |
initially Time_Span_Zero. The type Group_Budget_Handler identifies a protected |
| 4589 |
procedure to be executed by the implementation when the budget is |
| 4590 |
@i<exhausted>, that is, reaches zero. Such a protected procedure is called a |
| 4591 |
@i<handler>.@Defn{budget}@Defn2{Term=[exhaust],Sec=[a budget]} |
| 4592 |
@PDefn2{Term=[handler],Sec=[group budget]}]} |
| 4593 |
|
| 4594 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4595 |
@ChgAdded{Version=[2],Text=[An object of type Group_Budget also includes a |
| 4596 |
handler, which is a value of type Group_Budget_Handler. The handler of the |
| 4597 |
object is said to be @i<set> if it is not null and @i<cleared> otherwise. The |
| 4598 |
handler of all Group_Budget objects is initially cleared. |
| 4599 |
@PDefn2{Term=[set],Sec=[group budget object]} |
| 4600 |
@PDefn2{Term=[clear],Sec=[group budget object]}]} |
| 4601 |
|
| 4602 |
@begin{Discussion} |
| 4603 |
@ChgRef{Version=[2],Kind=[AddedNormal]} @ChgAdded{Version=[2],Text=[Type |
| 4604 |
Group_Budget is tagged. This makes it possible to share a handler between |
| 4605 |
several events. In simple cases, 'Access can be used to compare the parameter |
| 4606 |
with a specific group budget object (this works because a tagged type is a |
| 4607 |
by-reference type). In more complex cases, a type extension of type |
| 4608 |
Group_Budget can be declared; a double type conversion can be used to access |
| 4609 |
the extension data. An example of how this can be done can be found for the |
| 4610 |
similar type Timing_Event, see @RefSecNum{Timing Events}.]} |
| 4611 |
@end{Discussion} |
| 4612 |
|
| 4613 |
@end{StaticSem} |
| 4614 |
|
| 4615 |
@begin{RunTime} |
| 4616 |
|
| 4617 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4618 |
@ChgAdded{Version=[2],Text=[The procedure Add_Task adds the task identified by |
| 4619 |
T to the group GB; if that task is already a member of some other group, |
| 4620 |
Group_Budget_Error is raised.]} |
| 4621 |
|
| 4622 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4623 |
@ChgAdded{Version=[2],Text=[The procedure Remove_Task removes the task |
| 4624 |
identified by T from the group GB; if that task is not a member of the group |
| 4625 |
GB, Group_Budget_Error is raised. After successful execution of this procedure, |
| 4626 |
the task is no longer a member of any group.]} |
| 4627 |
|
| 4628 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4629 |
@ChgAdded{Version=[2],Text=[The function Is_Member returns True if the task |
| 4630 |
identified by T is a member of the group GB; otherwise it return False.]} |
| 4631 |
|
| 4632 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4633 |
@ChgAdded{Version=[2],Text=[The function Is_A_Group_Member returns True if the |
| 4634 |
task identified by T is a member of some group; otherwise it returns False.]} |
| 4635 |
|
| 4636 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4637 |
@ChgAdded{Version=[2],Text=[The function Members returns an array of values of |
| 4638 |
type Task_Identification.Task_Id identifying the members of the group GB. The |
| 4639 |
order of the components of the array is unspecified.]} |
| 4640 |
|
| 4641 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4642 |
@ChgAdded{Version=[2],Text=[The procedure Replenish loads the group budget GB |
| 4643 |
with To as the Time_Span value. The exception Group_Budget_Error is raised if |
| 4644 |
the Time_Span value To is non-positive. Any execution of any member of the |
| 4645 |
group of tasks results in the budget counting down, unless exhausted. When the |
| 4646 |
budget becomes exhausted (reaches Time_Span_Zero), the associated handler is |
| 4647 |
executed if the handler of group budget GB is set. Nevertheless, the tasks |
| 4648 |
continue to execute.]} |
| 4649 |
|
| 4650 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4651 |
@ChgAdded{Version=[2],Text=[The procedure Add modifies the budget of the group |
| 4652 |
GB. A positive value for Interval increases the budget. A negative value for |
| 4653 |
Interval reduces the budget, but never below Time_Span_Zero. A zero value for |
| 4654 |
Interval has no effect. A call of procedure Add that results in the value of |
| 4655 |
the budget going to Time_Span_Zero causes the associated handler to be executed |
| 4656 |
if the handler of the group budget GB is set.]} |
| 4657 |
|
| 4658 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4659 |
@ChgAdded{Version=[2],Text=[The function Budget_Has_Expired returns True if the |
| 4660 |
budget of group GB is exhausted (equal to Time_Span_Zero); otherwise it |
| 4661 |
returns False.]} |
| 4662 |
|
| 4663 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4664 |
@ChgAdded{Version=[2],Text=[The function Budget_Remaining returns the remaining |
| 4665 |
budget for the group GB. If the budget is exhausted it returns Time_Span_Zero. |
| 4666 |
This is the minimum value for a budget.]} |
| 4667 |
|
| 4668 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4669 |
@ChgAdded{Version=[2],Text=[The procedure Set_Handler associates the handler |
| 4670 |
Handler with the Group_Budget GB; if Handler is @b<null>, the handler of |
| 4671 |
Group_Budget is cleared, otherwise it is set.]} |
| 4672 |
|
| 4673 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4674 |
@ChgAdded{Version=[2],Text=[A call of Set_Handler for a Group_Budget that |
| 4675 |
already has a handler set replaces the handler; if Handler is not @b<null>, the |
| 4676 |
handler for Group_Budget remains set.]} |
| 4677 |
|
| 4678 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4679 |
@ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler |
| 4680 |
associated with the group budget GB if the handler for that group budget is |
| 4681 |
set; otherwise it returns @b<null>.]} |
| 4682 |
|
| 4683 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4684 |
@ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the handler for |
| 4685 |
the group budget if it is set. Cancelled is assigned True if the handler for |
| 4686 |
the group budget was set prior to it being cleared; otherwise it is assigned |
| 4687 |
False.]} |
| 4688 |
|
| 4689 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4690 |
@ChgAdded{Version=[2],Text=[The constant Min_Handler_Ceiling is the |
| 4691 |
minimum ceiling priority required for a protected object with a handler to |
| 4692 |
ensure that no ceiling violation will occur when that handler is invoked.]} |
| 4693 |
|
| 4694 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4695 |
@ChgAdded{Version=[2],Text=[The precision of the accounting of task execution |
| 4696 |
time to a Group_Budget is the same as that defined for execution-time clocks |
| 4697 |
from the parent package.]} |
| 4698 |
|
| 4699 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4700 |
@ChgAdded{Version=[2],Text=[As part of the finalization of an object of type |
| 4701 |
Group_Budget all member tasks are removed from the group identified by that |
| 4702 |
object.]} |
| 4703 |
|
| 4704 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4705 |
@ChgAdded{Version=[2],Text=[If a task is a member of a Group_Budget when it |
| 4706 |
terminates then as part of the finalization of the task it is removed from the |
| 4707 |
group.]} |
| 4708 |
|
| 4709 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4710 |
@ChgAdded{Version=[2],Text=[For all the operations defined in this package, |
| 4711 |
Tasking_Error is raised if the task identified by T has terminated, and |
| 4712 |
Program_Error is raised if the value of T is |
| 4713 |
Task_Identification.Null_Task_Id.]} |
| 4714 |
|
| 4715 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4716 |
@ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked when |
| 4717 |
the budget of a group of tasks becomes exhausted has no effect.]} |
| 4718 |
|
| 4719 |
@end{RunTime} |
| 4720 |
|
| 4721 |
@begin{Erron} |
| 4722 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4723 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)} |
| 4724 |
For a call of any of the subprograms defined in this package, if the task |
| 4725 |
identified by T no longer exists, the execution of the program is erroneous.]} |
| 4726 |
@end{Erron} |
| 4727 |
|
| 4728 |
@begin{ImplReq} |
| 4729 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4730 |
@ChgAdded{Version=[2],Text=[For a given Group_Budget object, the implementation |
| 4731 |
shall perform the operations declared in this package atomically with respect |
| 4732 |
to any of these operations on the same Group_Budget object. The replacement of |
| 4733 |
a handler, by a call of Set_Handler, shall be performed atomically with respect |
| 4734 |
to the execution of the handler.]} |
| 4735 |
@begin{Reason} |
| 4736 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4737 |
@ChgAdded{Version=[2],Text=[This prevents various race conditions. In |
| 4738 |
particular it ensures that if the budget is exhausted when Set_Handler |
| 4739 |
is changing the handler then either the new or old handler is executed |
| 4740 |
and the exhausting event is not lost.]} |
| 4741 |
@end{Reason} |
| 4742 |
@end{ImplReq} |
| 4743 |
|
| 4744 |
@begin{Notes} |
| 4745 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4746 |
@ChgAdded{Version=[2],Text=[Clearing or setting of the handler of a group |
| 4747 |
budget does not change the current value of the budget. Exhaustion or loading |
| 4748 |
of a budget does not change whether the handler of the group budget is set or |
| 4749 |
cleared.]} |
| 4750 |
|
| 4751 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4752 |
@ChgAdded{Version=[2],Text=[A Group_Budget_Handler can be associated with |
| 4753 |
several Group_Budget objects.]} |
| 4754 |
@end{Notes} |
| 4755 |
|
| 4756 |
@begin{Extend95} |
| 4757 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]} |
| 4758 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 4759 |
The package Execution_Time.Group_Budgets is new.]} |
| 4760 |
@end{Extend95} |
| 4761 |
|
| 4762 |
|
| 4763 |
@LabeledAddedClause{Version=[2],Name=[Timing Events]} |
| 4764 |
|
| 4765 |
@begin{Intro} |
| 4766 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4767 |
@ChgAdded{Version=[2],Text=[This clause describes a language-defined package to |
| 4768 |
allow user-defined protected procedures to be executed at a specified time |
| 4769 |
without the need for a task or a delay statement.]} |
| 4770 |
@end{Intro} |
| 4771 |
|
| 4772 |
@begin{StaticSem} |
| 4773 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4774 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following |
| 4775 |
language-defined library package exists:]} |
| 4776 |
@begin{Example} |
| 4777 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4778 |
@ChgAdded{Version=[2],Text=[@key{package} Ada.Real_Time.Timing_Events @key{is}@ChildUnit{Parent=[Ada.Real_Time],Child=[Timing_Events]}]} |
| 4779 |
|
| 4780 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4781 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timing_Event} @key{is tagged limited private}; |
| 4782 |
@key{type} @AdaTypeDefn{Timing_Event_Handler} |
| 4783 |
@key{is access protected procedure} (Event : @key{in out} Timing_Event);]} |
| 4784 |
|
| 4785 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4786 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (Event : @key{in out} Timing_Event; |
| 4787 |
At_Time : @key{in} Time; |
| 4788 |
Handler : @key{in} Timing_Event_Handler); |
| 4789 |
@key{procedure} @AdaSubDefn{Set_Handler} (Event : @key{in out} Timing_Event; |
| 4790 |
In_Time : @key{in} Time_Span; |
| 4791 |
Handler : @key{in} Timing_Event_Handler); |
| 4792 |
@key{function} @AdaSubDefn{Current_Handler} (Event : Timing_Event) |
| 4793 |
@key{return} Timing_Event_Handler; |
| 4794 |
@key{procedure} @AdaSubDefn{Cancel_Handler} (Event : @key{in out} Timing_Event; |
| 4795 |
Cancelled : @key{out} Boolean);]} |
| 4796 |
|
| 4797 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4798 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Of_Event} (Event : Timing_Event) @key{return} Time;]} |
| 4799 |
|
| 4800 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4801 |
@ChgAdded{Version=[2],Text=[@key{private} |
| 4802 |
... -- @RI[not specified by the language] |
| 4803 |
@key{end} Ada.Real_Time.Timing_Events;]} |
| 4804 |
@end{Example} |
| 4805 |
|
| 4806 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4807 |
@ChgAdded{Version=[2],Text=[The type Timing_Event represents a time in the future |
| 4808 |
when an event is to occur. The type Timing_Event needs finalization (see |
| 4809 |
@RefSecNum{User-Defined Assignment and Finalization}).]} |
| 4810 |
|
| 4811 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4812 |
@ChgAdded{Version=[2],Text=[An object of type Timing_Event is said to be |
| 4813 |
@i<set> if it is associated with a non-null value of type Timing_Event_Handler |
| 4814 |
and @i<cleared> otherwise. All Timing_Event objects are initially cleared. |
| 4815 |
@PDefn2{Term=[set],Sec=[timing event object]} |
| 4816 |
@PDefn2{Term=[clear],Sec=[timing event object]}]} |
| 4817 |
|
| 4818 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4819 |
@ChgAdded{Version=[2],Text=[The type Timing_Event_Handler identifies a |
| 4820 |
protected procedure to be executed by the implementation when the timing event |
| 4821 |
occurs. Such a protected procedure is called a @i{handler}. |
| 4822 |
@PDefn2{Term=[handler],Sec=[timing event]}]} |
| 4823 |
|
| 4824 |
@begin{Discussion} |
| 4825 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4826 |
@ChgAdded{Version=[2],Type=[Leading],Text=[Type Timing_Event is tagged. This |
| 4827 |
makes it possible to share a handler between several events. In simple cases, |
| 4828 |
'Access can be used to compare the parameter with a specific timing event |
| 4829 |
object (this works because a tagged type is a by-reference type). In more |
| 4830 |
complex cases, a type extension of type Timing_Event can be declared; a |
| 4831 |
double type conversion can be used to access the extension data. For |
| 4832 |
example:]} |
| 4833 |
|
| 4834 |
@begin{Example} |
| 4835 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4836 |
@ChgAdded{Version=[2],Text=[@key{type} Toaster_Timing_Event @key{is new} Timing_Event @key{with record} |
| 4837 |
Slot : Natural; |
| 4838 |
@key{end record};]} |
| 4839 |
|
| 4840 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4841 |
@ChgAdded{Version=[2],Text=[...]} |
| 4842 |
|
| 4843 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4844 |
@ChgAdded{Version=[2],Text=[@key{protected body} Toaster @key{is}]} |
| 4845 |
|
| 4846 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4847 |
@ChgAdded{Version=[2],Text=[ @key{procedure} Timer(Event : @key{in out} Timing_Event) @key{is} |
| 4848 |
@key{begin} |
| 4849 |
Pop_Up_Toast (Toaster_Timing_Event(Timing_Event'Class(Event)).Slot); |
| 4850 |
@key{end} Timer;]} |
| 4851 |
|
| 4852 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4853 |
@ChgAdded{Version=[2],Text=[ ... |
| 4854 |
@key{end} Toaster;]} |
| 4855 |
@end{Example} |
| 4856 |
|
| 4857 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4858 |
@ChgAdded{Version=[2],Text=[The extra conversion to the class-wide type |
| 4859 |
is necessary to make the conversions legal. While this usage is clearly |
| 4860 |
ugly, we think that the need for this sort of usage will be rare, so |
| 4861 |
we can live with it. It's certainly better than having no way to associate |
| 4862 |
data with an event.]} |
| 4863 |
@end{Discussion} |
| 4864 |
|
| 4865 |
@end{StaticSem} |
| 4866 |
|
| 4867 |
@begin{Runtime} |
| 4868 |
|
| 4869 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4870 |
@ChgAdded{Version=[2],Text=[The procedures Set_Handler associate the handler |
| 4871 |
Handler with the event Event; if Handler is @key{null}, the event is cleared, |
| 4872 |
otherwise it is set. The first procedure Set_Handler sets the execution time |
| 4873 |
for the event to be At_Time. The second procedure Set_Handler sets the |
| 4874 |
execution time for the event to be Real_Time.Clock + In_Time.]} |
| 4875 |
|
| 4876 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4877 |
@ChgAdded{Version=[2],Text=[A call of a procedure Set_Handler for an event that |
| 4878 |
is already set replaces the handler and the time of execution; if Handler is |
| 4879 |
not @key{null}, the event remains set.]} |
| 4880 |
|
| 4881 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4882 |
@ChgAdded{Version=[2],Text=[As soon as possible after the time set for the |
| 4883 |
event, the handler is executed, passing the event as parameter. The handler is |
| 4884 |
only executed if the timing event is in the set state at the time of execution. |
| 4885 |
The initial action of the execution of the handler is to clear the event.]} |
| 4886 |
|
| 4887 |
@begin{Reason} |
| 4888 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4889 |
@ChgAdded{Version=[2],Text=[The second sentence of this paragraph is because |
| 4890 |
of a potential race condition. The time might expire and yet before the |
| 4891 |
handler is executed, some task could call Cancel_Handler (or equivalently |
| 4892 |
call Set_Handler with a @key{null} parameter) and thus clear the handler.]} |
| 4893 |
@end{Reason} |
| 4894 |
|
| 4895 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4896 |
@ChgAdded{Version=[2],Text=[If the Ceiling_Locking policy (see |
| 4897 |
@RefSecNum{Priority Ceiling Locking}) is in effect when a procedure |
| 4898 |
Set_Handler is called, a check is made that the ceiling priority of |
| 4899 |
Handler.@key{all} is Interrupt_Priority'Last. If the check fails, Program_Error |
| 4900 |
is raised.]} |
| 4901 |
|
| 4902 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4903 |
@ChgAdded{Version=[2],Text=[If a procedure Set_Handler is called with zero or |
| 4904 |
negative In_Time or with At_Time indicating a time in the past then the handler |
| 4905 |
is executed immediately by the task executing the call of Set_Handler. The |
| 4906 |
timing event Event is cleared.]} |
| 4907 |
|
| 4908 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4909 |
@ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler |
| 4910 |
associated with the event Event if that event is set; otherwise it returns |
| 4911 |
@key{null}.]} |
| 4912 |
|
| 4913 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4914 |
@ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the event if it |
| 4915 |
is set. Cancelled is assigned True if the event was set prior to it being |
| 4916 |
cleared; otherwise it is assigned False.]} |
| 4917 |
|
| 4918 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4919 |
@ChgAdded{Version=[2],Text=[The function Time_Of_Event returns the time of the |
| 4920 |
event if the event is set; otherwise it returns Real_Time.Time_First.]} |
| 4921 |
|
| 4922 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4923 |
@ChgAdded{Version=[2],Text=[As part of the finalization of an object |
| 4924 |
of type Timing_Event, the Timing_Event is cleared.]} |
| 4925 |
|
| 4926 |
@begin{ImplNote} |
| 4927 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4928 |
@ChgAdded{Version=[2],Text=[This is the only finalization defined by the |
| 4929 |
language that has a visible effect; but an implementation may have other |
| 4930 |
finalization that it needs to perform. Implementations need to ensure that |
| 4931 |
the event is cleared before anything else is finalized that would prevent |
| 4932 |
a set event from being triggered.]} |
| 4933 |
@end{ImplNote} |
| 4934 |
|
| 4935 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4936 |
@ChgAdded{Version=[2],Text=[If several timing events are set for the same time, |
| 4937 |
they are executed in FIFO order of being set.]} |
| 4938 |
|
| 4939 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4940 |
@ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked by a |
| 4941 |
timing event has no effect.]} |
| 4942 |
|
| 4943 |
@end{Runtime} |
| 4944 |
|
| 4945 |
@begin{ImplReq} |
| 4946 |
|
| 4947 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4948 |
@ChgAdded{Version=[2],Text=[For a given Timing_Event object, the implementation |
| 4949 |
shall perform the operations declared in this package atomically with respect |
| 4950 |
to any of these operations on the same Timing_Event object. The replacement of |
| 4951 |
a handler by a call of Set_Handler shall be performed atomically with respect |
| 4952 |
to the execution of the handler.]} |
| 4953 |
|
| 4954 |
@begin{Reason} |
| 4955 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4956 |
@ChgAdded{Version=[2],Text=[This prevents various race conditions. In |
| 4957 |
particular it ensures that if an event occurs when Set_Handler is changing |
| 4958 |
the handler then either the new or old handler is executed in response to the |
| 4959 |
appropriate event. It is never possible for a new handler to be executed in |
| 4960 |
response to an old event.]} |
| 4961 |
@end{Reason} |
| 4962 |
@end{ImplReq} |
| 4963 |
|
| 4964 |
@begin{Metrics} |
| 4965 |
|
| 4966 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4967 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The implementation shall document |
| 4968 |
the following metric:]} |
| 4969 |
@begin{Itemize} |
| 4970 |
|
| 4971 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4972 |
@ChgAdded{Version=[2],Text=[An upper bound on the lateness of the execution of |
| 4973 |
a handler. That is, the maximum time between when a handler is actually |
| 4974 |
executed and the time specified when the event was set.]} |
| 4975 |
|
| 4976 |
@end{Itemize} |
| 4977 |
@ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4978 |
Text=[The metrics for timing events.]}]} |
| 4979 |
@end{Metrics} |
| 4980 |
|
| 4981 |
@begin{ImplAdvice} |
| 4982 |
|
| 4983 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4984 |
@ChgAdded{Version=[2],Text=[The protected handler procedure should be executed |
| 4985 |
directly by the real-time clock interrupt mechanism.]} |
| 4986 |
|
| 4987 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4988 |
Text=[For a timing event, the handler should be executed directly by the |
| 4989 |
real-time clock interrupt mechanism.]}]} |
| 4990 |
|
| 4991 |
@end{ImplAdvice} |
| 4992 |
|
| 4993 |
@begin{Notes} |
| 4994 |
|
| 4995 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 4996 |
@ChgAdded{Version=[2],Text=[Since a call of Set_Handler is not a potentially |
| 4997 |
blocking operation, it can be called from within a handler.]} |
| 4998 |
|
| 4999 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 5000 |
@ChgAdded{Version=[2],Text=[A Timing_Event_Handler can be associated with several |
| 5001 |
Timing_Event objects.]} |
| 5002 |
|
| 5003 |
@end{Notes} |
| 5004 |
|
| 5005 |
@begin{Extend95} |
| 5006 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]} |
| 5007 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 5008 |
The package Real_Time.Timing_Events is new.]} |
| 5009 |
@end{Extend95} |
| 5010 |
|