Debian Codegraph @

source_2012/rt.mss

raw
1 @Comment{ $Source: e:\\cvsroot/ARM/Source/rt.mss,v $ }
2 @comment{ $Revision: 1.120 $ $Date: 2016/02/12 05:25:38 $ $Author: randy $ }
3 @Part(realtime, Root="ada.mss")
4 @Comment{$Date: 2016/02/12 05:25:38 $}
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],InitialVersion=[0],
23 Text=[@ChgDeleted{Version=[2],
24 Text=[Values of all @MetricsTitle.]}]}@ChgNote{We're going to document the
25 individual metrics sections.}
26 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
27 Text=[The details of the configuration used to generate the values of all
28 metrics.]}]}
29 @begin{Reason}
30 The actual values of the metrics are likely to depend on hardware
31 configuration details that are variable and generally outside the control
32 of a compiler vendor.
33 @end{Reason}
34
35 The metrics do not necessarily yield a simple number.
36 @Redundant[For some, a range is more suitable, for others a formula
37 dependent on some parameter is appropriate, and for
38 others,
39 it may be more suitable to break the metric into several cases.]
40 Unless specified otherwise, the metrics in this annex are expressed in
41 processor clock cycles.
42 For metrics that require documentation of an upper bound,
43 if there is no upper bound,
44 the implementation shall report that the metric is unbounded.
45 @begin{Discussion}
46 There are several good reasons to specify metrics in seconds; there are however
47 equally good reasons to specify them in processor clock cycles. In
48 defining the metrics, we have tried to strike a balance on a case-by-case
49 basis.
50
51 It has been suggested that all metrics should be given names,
52 so that @lquotes@;data-sheets@rquotes@; could be formulated and published
53 by vendors.
54 However the paragraph number can serve that purpose.
55 @end{Discussion}
56
57 @end{Metrics}
58
59 @begin{Notes}
60
61 The specification of the metrics makes a distinction between upper bounds
62 and simple execution times. Where something is just specified as @lquotes@;the
63 execution time of@rquotes@; a piece of code, this leaves one
64 the freedom
65 to choose a nonpathological case. This kind of metric is of the form
66 @lquotes@;there exists a program such that the value of the metric is V@rquotes@;.
67 Conversely, the meaning of upper bounds is @lquotes@;there is no program such
68 that the value of the metric is greater than V@rquotes@;.
69 This kind of metric can only be partially tested, by finding the value
70 of V for one or more test programs.
71
72 The metrics do not cover the whole language; they are limited
73 to features that are specified in @RefSec{Systems Programming}
74 and in this Annex. The metrics are intended
75 to provide guidance to potential users as to whether a particular
76 implementation of such a feature is going to be adequate for a
77 particular real-time application. As such, the metrics are aimed
78 at known implementation choices that can result in significant
79 performance differences.
80
81 The purpose of the metrics is not necessarily to provide fine-grained
82 quantitative results or to serve as a comparison between different
83 implementations on the same or different platforms. Instead, their
84 goal is rather qualitative; to define a standard set of approximate values
85 that can be measured and used to estimate the general suitability of an
86 implementation, or to evaluate the comparative utility of certain features
87 of an implementation for a particular real-time application.
88
89 @end{Notes}
90
91 @begin{Extend83}
92 @Defn{extensions to Ada 83}
93 This Annex is new to Ada 95.
94 @end{Extend83}
95
96
97 @LabeledClause{Task Priorities}
98 @begin{Intro}
99 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
100 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
101 the priority model for real-time systems.
102 In addition, the methods for specifying priorities are defined.]
103 @end{Intro}
104
105 @begin{NotIso}
106 @ChgAdded{Version=[3],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 2
107 through 6 were moved to @RefSec{Obsolescent Features}.>}]}@Comment{This message
108 should be deleted if the paragraphs are ever renumbered.}
109 @end{NotIso}
110
111 @begin{Syntax}
112 @begin{SyntaxText}
113 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
114 @ChgDeleted{Version=[3],Type=[Leading],KeepNext=[T],Text=[The form of a
115 @nt{pragma} Priority is as follows:]}
116 @end{SyntaxText}
117
118 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
119 @DeletedPragmaSyn<Version=[3],InitialVersion=[0],@ChgDeleted{Version=[3],
120 Text=[@key{pragma} @prag(Priority)(@Syn2{expression});]}>
121
122 @begin{SyntaxText}
123 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
124 @ChgDeleted{Version=[3],Type=[Leading],KeepNext=[T],Text=[The form of a
125 @nt{pragma} Interrupt_Priority is as follows:]}
126 @end{SyntaxText}
127
128 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
129 @DeletedPragmaSyn<Version=[3],InitialVersion=[0],@ChgDeleted{Version=[3],
130 Text=[@key{pragma} @prag(Interrupt_Priority)[(@Syn2{expression})];]}>
131 @end{Syntax}
132
133 @begin{Resolution}
134
135 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
136 @ChgDeleted{Version=[3],Text=[@PDefn2{Term=[expected type],
137 Sec=(Priority pragma argument)}
138 @PDefn2{Term=[expected type],
139 Sec=(Interrupt_Priority pragma argument)}
140 The expected type for the @nt{expression} in a Priority
141 or Interrupt_Priority pragma is Integer.]}
142 @end{Resolution}
143
144 @begin{StaticSem}
145 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
146 @ChgAdded{Version=[3],Type=[Leading],Text=[For a task type (including the
147 anonymous type of a @nt{single_task_declaration}), protected type (including the
148 anonymous type of a @nt{single_protected_declaration}), or subprogram,
149 the following language-defined representation aspects may be specified:]}
150
151 @begin{Description}
152 @ChgRef{Version=[3],Kind=[Added]}
153 @ChgAdded{Version=[3],Text=[Priority@\The aspect Priority is
154 an @nt{expression}, which shall be of type Integer.@AspectDefn{Priority}]}
155
156 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Priority],
157 Text=[@ChgAdded{Version=[3],Text=[Priority of a task object or type, or
158 priority of a protected object or type; the priority is not in the
159 interrupt range.]}]}
160
161 @ChgRef{Version=[3],Kind=[Added]}
162 @ChgAdded{Version=[3],Text=[Interrupt_Priority@\The aspect
163 Interrupt_Priority is an @nt{expression}, which shall be of type
164 Integer.@AspectDefn{Interrupt_Priority}]}
165
166 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Interrupt_Priority],
167 Text=[@ChgAdded{Version=[3],Text=[Priority of a task object or type, or
168 priority of a protected object or type; the priority is in the
169 interrupt range.]}]}
170
171 @end{Description}
172 @end{StaticSem}
173
174
175 @begin{Legality}
176
177 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0229-1]}
178 @ChgDeleted{Version=[3],Text=[A Priority pragma is allowed only immediately
179 within a @nt{task_definition}, a @nt{protected_definition}, or the
180 @nt{declarative_part} of a @nt{subprogram_body}. An Interrupt_Priority pragma is
181 allowed only immediately within a @nt{task_definition} or a
182 @nt{protected_definition}. At most one such pragma shall appear within a given
183 construct.]}
184
185 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
186 @Chg{Version=[3],New=[If the],Old=[For a]} Priority @Chg{Version=[3],New=[aspect
187 is specified for a subprogram],Old=[pragma that appears in the
188 @nt{declarative_part} of a @nt{subprogram_body}]}, the @nt{expression} shall be
189 static, and its value shall be in the range of System.Priority.
190 @begin{Reason}
191 This value is needed before it gets elaborated, when the environment task
192 starts executing.
193 @end{Reason}
194
195 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
196 @ChgAdded{Version=[3],Text=[At most one of the Priority and Interrupt_Priority
197 aspects may be specified for a given entity.]}
198
199 @begin{Ramification}
200 @ChgRef{Version=[3],Kind=[AddedNormal]}
201 @ChgAdded{Version=[3],Text=[This includes specifying via pragmas
202 (see @RefSecNum{Pragmas Priority and Interrupt_Priority}). Note that
203 @RefSecNum{Operational and Representation Aspects} prevents multiple
204 specifications of a single representation aspect by any means.]}
205 @end{Ramification}
206
207 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
208 @ChgAdded{Version=[3],Text=[Neither of the Priority or Interrupt_Priority
209 aspects shall be specified for a synchronized interface type.]}
210
211 @end{Legality}
212
213 @begin{StaticSem}
214
215 @leading@keepnext@;The following declarations exist in package System:
216 @begin{example}
217 @key{subtype} Any_Priority @key{is} Integer @key{range} @RI{implementation-defined};
218 @key{subtype} Priority @key{is} Any_Priority
219 @key{range} Any_Priority'First .. @RI{implementation-defined};
220 @key{subtype} Interrupt_Priority @key{is} Any_Priority
221 @key{range} Priority'Last+1 .. Any_Priority'Last;
222
223 Default_Priority : @key{constant} Priority := (Priority'First + Priority'Last)/2;
224 @end{example}
225 @ImplDef{The declarations of Any_Priority and Priority.}
226
227 The full range of priority values supported by an implementation is specified
228 by the subtype Any_Priority. The subrange of priority values that are high
229 enough to require the blocking of one or more interrupts is specified by the
230 subtype Interrupt_@!Priority. @Redundant[The subrange of priority values below
231 System.@!Interrupt_@!Priority'First is specified by the subtype System.@!Priority.]
232
233 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0229-1]}
234 @ChgDeleted{Version=[3],Text=[The priority specified by a Priority or
235 Interrupt_Priority pragma is the value of the @nt{expression} in the pragma, if
236 any. If there is no @nt{expression} in an Interrupt_Priority pragma, the
237 priority value is Interrupt_Priority'Last.]}
238
239 @end{StaticSem}
240
241 @begin{RunTime}
242
243 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
244 @Chg{Version=[3],New=[The],Old=[A]} Priority
245 @Chg{Version=[3],New=[aspect],Old=[pragma]} has no effect
246 if it @Chg{Version=[3],New=[is specified for],Old=[it occurs
247 in the @nt{declarative_part} of the @nt{subprogram_body} of]} a
248 subprogram other than the main subprogram@Chg{Version=[3],New=[; the Priority
249 value is not associated with any task],Old=[]}.
250
251 @Defn{task priority}
252 @Defn{priority}
253 @Defn{priority inheritance}
254 @Defn{base priority}
255 @Defn{active priority}
256 A @i{task priority} is an integer value that indicates a degree of urgency
257 and is the basis for resolving competing demands of tasks for
258 resources. Unless otherwise specified, whenever tasks compete
259 for processors or other implementation-defined resources, the
260 resources are allocated to the task with the highest priority
261 value.
262 The @i{base priority} of a task is the priority with which it was
263 created, or to which it was later set by Dynamic_Priorities.Set_Priority
264 (see @RefSecNum{Dynamic Priorities}). At all times, a task also has
265 an @i{active priority}, which generally reflects its base priority
266 as well as any priority it inherits from other sources.
267 @i{Priority inheritance} is the process by which the priority of a
268 task or other entity (e.g. a protected object;
269 see @RefSecNum{Priority Ceiling Locking}) is used in the evaluation of another
270 task's active priority.
271 @ImplDef{Implementation-defined execution resources.}
272
273 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
274 The effect of specifying @Chg{Version=[3],New=[a Priority or
275 Interrupt_Priority aspect for a protected type or
276 @nt{single_protected_declaration}],Old=[such a pragma
277 in a @nt{protected_definition}]}
278 is discussed in @RefSecNum{Priority Ceiling Locking}.
279
280 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
281 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0081-1]}
282 @Defn2{Term=[creation], Sec=(of a task object)}
283 The @nt{expression} @Chg{Version=[3],New=[specified for the],Old=[in a]}
284 Priority or Interrupt_Priority @Chg{Version=[3],New=[aspect of a
285 task@Chg{Version=[4],New=[ type],Old=[]}],Old=[pragma that
286 appears in a @nt{task_definition}]} is evaluated
287 @Chg{Version=[4],New=[],Old=[for ]}each
288 @Chg{Version=[4],New=[time an],Old=[task]}
289 object@Chg{Version=[4],New=[ of the task type is created],Old=[]}
290 (see @RefSecNum{Task Units and Task Objects}).
291 For @Chg{Version=[3],New=[the],Old=[a]} Priority @Chg{Version=[3],New=[aspect],Old=[pragma]},
292 the value of the @nt{expression} is converted to the subtype Priority;
293 for @Chg{Version=[3],New=[the],Old=[an]}
294 Interrupt_Priority @Chg{Version=[3],New=[aspect],Old=[pragma]}, this value
295 is converted to the subtype Any_Priority.
296 The priority value is then associated with the task
297 object@Chg{Version=[4],New=[],Old=[whose @Chg{Version=[3],New=[task declaration
298 specifies the aspect],Old=[@nt{task_definition} contains the pragma]}]}.
299 @Chg{Version=[3],New=[@PDefn2{Term=[implicit subtype conversion],Sec=(Priority aspect)}
300 @PDefn2{Term=[implicit subtype conversion],Sec=(Interrupt_Priority aspect)}],
301 Old=[@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)}
302 @PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)}]}
303
304 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
305 Likewise, the priority value is associated with the environment task if the
306 @Chg{Version=[3],New=[aspect is specified for],Old=[pragma appears in the
307 @nt{declarative_part} of]} the main subprogram.
308
309 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
310 The initial value of a task's base priority is specified by default or
311 by means of a Priority or Interrupt_Priority
312 @Chg{Version=[3],New=[aspect],Old=[pragma]}.
313 @Redundant[After a task is created,
314 its base priority can be changed only by a call to
315 Dynamic_Priorities.Set_Priority (see @RefSecNum{Dynamic Priorities}).]
316 The initial base priority of a task in the absence of
317 @Chg{Version=[3],New=[an aspect],Old=[a pragma]} is the
318 base priority of the task that creates it at the time of creation
319 (see @RefSecNum{Task Units and Task Objects}).
320 If @Chg{Version=[3],New=[the aspect],Old=[a pragma]} Priority
321 @Chg{Version=[3],New=[is not specified for],Old=[does not apply to]} the
322 main subprogram, the initial base priority of the environment task is
323 System.Default_Priority.
324 @Redundant[The task's active priority is used when the task competes for
325 processors.
326 Similarly, the task's active priority is used
327 to determine the task's position in any queue when Priority_Queuing is
328 specified (see @RefSecNum{Entry Queuing Policies}).]
329
330 @Leading@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]}
331 At any time, the active priority of a task is the maximum of all the
332 priorities the task is inheriting at that instant. For a task that is not
333 held (see @RefSecNum{Asynchronous Task Control}), its base priority is
334 @Chg{Version=[2],New=[],Old=[always ]}a source of priority inheritance
335 @Chg{Version=[2],New=[unless otherwise
336 specified for a particular task dispatching policy],Old=[]}.
337 Other sources of priority inheritance are specified under the following
338 conditions:
339 @begin{Discussion}
340 Other parts of the annex, e.g.
341 @RefSecNum{Asynchronous Task Control}, define
342 other sources of priority inheritance.
343 @end{Discussion}
344 @begin{itemize}
345
346 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0072],ARef=[AI95-00092-01]}
347 During activation, a task being activated inherits the active priority
348 @Chg{New=[that],Old=[of the]} its activator (see
349 @RefSecNum{Task Execution - Task Activation})@Chg{New=[ had at the time
350 the activation was initiated],Old=[]}.
351
352 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0072],ARef=[AI95-00092-01]}
353 During rendezvous, the task accepting the entry call inherits the
354 @Chg{New=[],Old=[active ]}priority of the @Chg{New=[entry call],Old=[caller]}
355 (see @RefSecNum{Entry Calls}@Chg{New=[ and @RefSecNum{Entry Queuing Policies}],Old=[]}).
356
357 During a protected action on a protected object, a task inherits the ceiling
358 priority of the protected object (see @RefSecNum{Intertask Communication} and
359 @RefSecNum{Priority Ceiling Locking}).
360
361 @end{itemize}
362
363 In all of these cases, the priority ceases to be
364 inherited as soon as the condition calling for the inheritance no longer
365 exists.
366
367 @end{RunTime}
368
369 @begin{ImplReq}
370
371 The range of System.Interrupt_Priority shall include at least one value.
372
373 The range of System.Priority shall include at least 30 values.
374
375 @end{ImplReq}
376
377 @begin{Notes}
378
379 The priority expression can include references to
380 discriminants of the enclosing type.
381
382 It is a consequence of the active priority rules that at the point when
383 a task stops inheriting a priority from another source, its active priority
384 is re-evaluated. This is in addition to other instances described in this
385 Annex for such re-evaluation.
386
387 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0248-1]}
388 An implementation may provide a
389 @Chg{Version=[3],New=[nonstandard],Old=[non-standard]} mode in which tasks
390 inherit priorities under conditions other than those specified above.
391 @begin{Ramification}
392 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
393 The use of a Priority or Interrupt_Priority
394 @Chg{Version=[3],New=[aspect],Old=[pragma]} does not
395 require the package System to be named in a @nt{with_clause} for the
396 enclosing @nt{compilation_unit}.
397 @end{Ramification}
398
399 @end{Notes}
400
401 @begin{Extend83}
402 @Defn{extensions to Ada 83}
403 The priority of a task is per-object and not per-type.
404
405 Priorities need not be static anymore (except for the main subprogram).
406
407 @end{Extend83}
408
409 @begin{DiffWord83}
410
411 The description of the Priority pragma has been moved to this annex.
412
413 @end{DiffWord83}
414
415 @begin{DiffWord95}
416 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0072],ARef=[AI95-00092-01]}
417 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that dynamic
418 priority changes are not transitive - that is, they don't apply to tasks
419 that are being activated by or in rendezvous with the task that had its
420 priority changed.]}
421
422 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
423 @ChgAdded{Version=[2],Text=[Generalized the definition of priority
424 inheritance to take into account the differences between the existing and
425 new dispatching policies.]}
426 @end{DiffWord95}
427
428 @begin{Extend2005}
429 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
430 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
431 Aspects Priority and Interrupt_Priority are new; @nt{pragma}s
432 Priority and Interrupt_Priority are now obsolescent.]}
433 @end{Extend2005}
434
435 @begin{DiffWord2012}
436 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0081-1]}
437 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified when the Priority
438 and Interrupt_Priority aspect expressions are evaluated.]}
439 @end{DiffWord2012}
440
441
442 @LabeledClause{Priority Scheduling}
443
444 @begin{Intro}
445 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
446 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
447 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
448 describes the rules that determine which task is
449 selected for execution when more than one task is ready
450 (see @Chg{Version=[2],New=[@RefSecNum{Tasks and Synchronization}],
451 Old=[@RefSecNum{Task Execution - Task Activation}]}).@Chg{Version=[2],
452 New=[],Old=[ The rules have two parts: the task dispatching model
453 (see @RefSecNum{The Task Dispatching Model}),
454 and a specific task dispatching policy
455 (see @RefSecNum{Task Dispatching Pragmas}).]}]
456 @end{Intro}
457
458 @begin{DiffWord95}
459 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
460 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
461 @ChgAdded{Version=[2],Text=[This introduction is simplified in order to
462 reflect the rearrangement and expansion of this @Chg{Version=[3],New=[subclause],Old=[clause]}.]}
463 @end{DiffWord95}
464
465
466 @LabeledSubClause{The Task Dispatching Model}
467
468 @begin{Intro}
469 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
470 @Redundant[The task dispatching model specifies @Chg{Version=[2],
471 New=[task],Old=[preemptive]} scheduling, based on conceptual
472 priority-ordered ready queues.]
473 @end{Intro}
474
475 @begin{StaticSem}
476 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
477 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
478 language-defined library package exists:]}
479 @begin{Example}
480 @ChgRef{Version=[2],Kind=[Added]}
481 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0166-1]}
482 @ChgAdded{Version=[2],Text=[@key<package> Ada.Dispatching @key<is>@ChildUnit{Parent=[Ada],Child=[Dispatching]}
483 @key<pragma> @Chg{Version=[3],New=[Preelaborate],Old=[Pure]}(Dispatching);@Chg{Version=[3],New=[],Old=[
484 @AdaExcDefn{Dispatching_Policy_Error} : @key<exception>;
485 @key<end> Ada.Dispatching;]}]}
486
487 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0166-1]}
488 @ChgAdded{Version=[3],Text=[ @key<procedure> @AdaSubDefn{Yield};]}
489
490 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0166-1]}
491 @ChgAdded{Version=[3],Text=[ @AdaExcDefn{Dispatching_Policy_Error} : @key<exception>;
492 @key<end> Ada.Dispatching;]}
493 @end{Example}
494
495 @ChgRef{Version=[2],Kind=[Added]}
496 @ChgAdded{Version=[2],Text=[Dispatching serves as the parent of other
497 language-defined library units concerned with task dispatching.]}
498
499 @end{StaticSem}
500
501 @begin{RunTime}
502
503 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
504 A task @Chg{Version=[2],New=[can become],Old=[runs (that is, it becomes]} a
505 @i{running task}@Chg{Version=[2],New=[],Old=[)]} only @Chg{Version=[2],
506 New=[if],Old=[when]} it is ready (see @Chg{Version=[2],New=[@RefSecNum{Tasks and Synchronization}],
507 Old=[@RefSecNum{Task Execution - Task Activation}]}) and
508 the execution resources required by that task are available.
509 Processors are allocated to tasks based on each task's active priority.
510
511 It is implementation defined whether, on a multiprocessor, a task that
512 is waiting for access to a protected object keeps its processor busy.
513 @ImplDef{Whether, on a multiprocessor, a task that
514 is waiting for access to a protected object keeps its processor busy.}
515
516 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
517 @Defn{task dispatching}
518 @Defn{dispatching, task}
519 @RootDefn{task dispatching point}
520 @RootDefn{dispatching point}
521 @i{Task dispatching} is the process by which one ready task is selected
522 for execution on a processor. This selection is done at certain points
523 during the execution of a task called @i{task dispatching points}.
524 A task reaches a task dispatching point whenever it becomes blocked,
525 and @Chg{Version=[2],New=[when it terminates],Old=[whenever it becomes ready.
526 In addition, the completion of an @nt{accept_statement}
527 (see @RefSecNum{Entries and Accept Statements}), and task termination are
528 task dispatching points for the executing task]}.
529 @Redundant[Other task dispatching points are defined
530 throughout this Annex@Chg{Version=[2],New=[ for specific policies],Old=[]}.]
531 @begin{Ramification}
532 On multiprocessor systems, more than one task can be chosen, at the
533 same time, for execution on more than one processor, as explained below.
534 @end{Ramification}
535
536 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
537 @Defn{ready queue}
538 @Defn{head (of a queue)}
539 @Defn{tail (of a queue)}
540 @Defn{ready task}
541 @PDefn{task dispatching policy}
542 @PDefn{dispatching policy for tasks}
543 @i{Task dispatching policies} are specified in terms of conceptual
544 @i{ready queues}@Chg{Version=[2],New=[ and],Old=[,]} task states@Chg{Version=[2],
545 New=[],Old=[, and task preemption]}.
546 A ready queue is an ordered list of ready tasks.
547 The first position in a queue is called the
548 @i{head of the queue}, and the last position is called the
549 @i{tail of the queue}.
550 A task is @i{ready} if it is in a ready queue,
551 or if it is running.
552 Each processor has one ready queue for each priority value. At any instant,
553 each ready queue of a processor contains exactly the set of tasks of that
554 priority that are ready for execution on that
555 processor, but are not running on any processor; that is, those tasks
556 that are ready, are not running on any processor, and can be
557 executed using that processor and other available resources.
558 A task can be on the ready queues of more than one processor.
559 @begin{Discussion}
560 The core language defines a ready task as one that is not
561 blocked. Here we refine this definition and
562 talk about ready queues.
563 @end{Discussion}
564
565 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
566 @Defn{running task}
567 Each processor also has one @i{running task},
568 which is the task currently being executed by that processor.
569 Whenever a task running on a processor reaches a task dispatching
570 point@Chg{Version=[2],New=[ it goes back to one or more ready queues; a],
571 Old=[, one]} task @Chg{Version=[2],New=[(possibly the same task) ],Old=[]}is
572 @Chg{Version=[2],New=[then ],Old=[]}selected to run on that processor.
573 The task selected is the one at the head of the highest priority
574 nonempty ready queue;
575 this task is then removed from all ready queues to which it
576 belongs.
577 @begin{Discussion}
578 There is always at least one task to run,
579 if we count the idle task.
580 @end{Discussion}
581
582 @ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00321-01]}
583 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0166-1]}
584 @ChgDeleted{Version=[2],Text=[@Defn{preemptible resource}
585 A preemptible resource is a resource that while allocated
586 to one task can be allocated (temporarily) to another
587 instead.
588 Processors are preemptible resources. Access to a protected object
589 (see @RefSecNum{Protected Subprograms and Protected Actions})
590 is a nonpreemptible resource.
591 @Defn{preempted task}
592 When a higher-priority task is dispatched to the processor, and the previously
593 running task is placed on the appropriate ready queue, the latter task
594 is said to be @i{preempted}.]}
595 @ChgAdded{Version=[3],Text=[A call of Yield is a task dispatching point. Yield
596 is a potentially blocking operation (see @RefSecNum{Protected Subprograms and Protected Actions}).]}
597 @begin{Reason}
598 @ChgRef{Version=[2],Kind=[Deleted]}
599 @ChgDeleted{Version=[2],Text=[A processor that is executing a task is available
600 to execute tasks of higher priority, within the set of tasks that that
601 processor is able to execute. Write access to a protected object, on the other
602 hand, cannot be granted to a new task before the old task has released it.]}
603 @end{Reason}
604
605 @ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00321-01]}
606 @ChgDeleted{Version=[2],Text=[@PDefn{task dispatching point}
607 @PDefn{dispatching point}
608 A new running task is also selected whenever there is a nonempty ready queue
609 with a higher priority than the priority of the running
610 task, or when the task dispatching policy requires a
611 running task to go back to a ready queue.
612 @Redundant[These are also task dispatching points.]]}
613 @begin{Ramification}
614 @ChgRef{Version=[2],Kind=[Deleted]}
615 @ChgDeleted{Version=[2],Text=[Thus, when a task becomes ready, this is a task
616 dispatching point for all running tasks of lower priority.]}
617 @end{Ramification}
618
619 @end{RunTime}
620
621 @begin{ImplPerm}
622
623 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
624 An implementation is allowed to define additional resources as execution
625 resources, and to define the corresponding allocation policies for them.
626 Such resources may have an implementation@Chg{Version=[2],New=[-],Old=[ ]}defined
627 effect on task dispatching@Chg{Version=[2],New=[],
628 Old=[ (see @RefSecNum{Task Dispatching Pragmas})]}.
629 @ChgImplDef{Version=[2],Kind=[Revised],InitialVersion=[0],
630 Text=[The @Chg{Version=[2],New=[effect],Old=[affect]} of
631 implementation@Chg{Version=[2],New=[-],Old=[ ]}defined
632 execution resources on task dispatching.]}
633
634 An implementation may place implementation-defined restrictions on
635 tasks whose active priority is in the Interrupt_Priority range.
636 @begin{Ramification}
637 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
638 For example, on some operating systems,
639 it might be necessary to disallow them altogether.
640 This permission applies to tasks whose priority is set to interrupt
641 level for any reason: via @Chg{Version=[3],New=[an aspect],Old=[a pragma]},
642 via a call to Dynamic_Priorities.Set_Priority,
643 or via priority inheritance.
644 @end{Ramification}
645
646 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00321-01]}
647 @ChgNote{This was moved up from the previous section.}
648 @ChgAdded{Version=[2],Text=[@Redundant[For optimization purposes,]
649 an implementation may alter the points at which task dispatching occurs, in an
650 implementation-defined manner. However, a @nt{delay_statement} always
651 corresponds to at least one task dispatching point.]}
652
653 @end{ImplPerm}
654
655 @begin{Notes}
656
657 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
658 @Chg{Version=[3],New=[Clause],Old=[Section]} @RefSecNum{Tasks and Synchronization}
659 specifies under which circumstances a task becomes ready.
660 The ready state is affected by the rules for
661 task activation and termination, delay statements, and entry calls.
662 @PDefn{blocked}
663 When a task is not ready, it is said to be blocked.
664
665 An example of a possible implementation-defined execution
666 resource is a page of physical memory, which needs to be loaded
667 with a particular page of virtual memory before a task can
668 continue execution.
669
670 The ready queues are purely conceptual; there is no requirement that such
671 lists physically exist in an implementation.
672
673 While a task is running, it is not on any ready queue. Any time
674 the task that is running on a processor is added to a ready queue,
675 a new running task is selected for that processor.
676
677 In a multiprocessor system, a task can be on the ready queues of more than
678 one processor. At the extreme, if several processors share the same set of
679 ready tasks, the contents of their ready queues is identical, and so
680 they can be viewed as sharing one ready queue, and can be implemented that
681 way.
682 @Redundant[Thus, the dispatching model covers
683 multiprocessors where dispatching is implemented using a single
684 ready queue, as well as those with separate dispatching domains.]
685
686 The priority of a task is determined by rules specified in this subclause, and
687 under @RefSec{Task Priorities}, @RefSec{Priority Ceiling Locking}, and
688 @RefSec{Dynamic Priorities}.
689
690 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
691 @ChgNote{This note is moved up from the next subclause.}
692 @ChgAdded{Version=[2],Text=[The setting of a task's base priority as a result
693 of a call to Set_Priority does not always take effect immediately when
694 Set_Priority is called. The effect of setting the task's base priority is
695 deferred while the affected task performs a protected action.]}
696
697 @end{Notes}
698
699 @begin{DiffWord95}
700 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
701 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
702 @ChgAdded{Version=[2],Text=[This description is simplified to describe only
703 the parts of the dispatching model common to all policies. In particular,
704 rules about preemption are moved elsewhere. This makes
705 it easier to add other policies (which @Chg{Version=[3],New=[might],Old=[may]}
706 not involve preemption).]}
707 @end{DiffWord95}
708
709 @begin{Incompatible2005}
710 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0166-1]}
711 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}
712 Procedure Yield is added to Dispatching.
713 If Dispatching is referenced in a @nt{use_clause}, and an
714 entity @i<E> with a @nt{defining_identifier} of Yield is
715 defined in a package that is also referenced in a @nt{use_clause}, the entity
716 @i<E> may no longer be use-visible, resulting in errors. This should be rare
717 and is easily fixed if it does occur.]}
718
719 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0166-1],ARef=[AI12-0005-1]}
720 @ChgAdded{Version=[4],Text=[Package Dispatching was a Pure package, but
721 now is Preelaborated with the addition of Yield. This is incompatible as
722 Dispatching can no longer be depended upon from a Pure package. This
723 should happen rarely in practice as the only contents was the exception
724 Dispatching_Policy_Error and none of the child packages that could raise
725 that exception are pure.]}
726 @end{Incompatible2005}
727
728
729 @LabeledRevisedSubClause{Version=[2],
730 New=[Task Dispatching Pragmas],
731 Old=[The Standard Task Dispatching Policy]}
732
733 @begin{Intro}
734 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
735 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
736 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
737 allows a single task
738 dispatching policy to be defined for all priorities, or the range of priorities
739 to be split into subranges that are assigned individual dispatching
740 policies.]]}
741 @end{Intro}
742
743 @begin{Syntax}
744 @begin{SyntaxText}
745 @Leading@Keepnext@;The form of a @nt{pragma} Task_Dispatching_Policy is as follows:
746 @end{SyntaxText}
747
748 @PragmaSyn`@key{pragma} @prag(Task_Dispatching_Policy)(@SynI{policy_}@Syn2{identifier});'
749
750 @begin{SyntaxText}
751 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
752 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The form of a
753 @nt{pragma} Priority_Specific_Dispatching is as follows:]}
754 @end{SyntaxText}
755
756 @ChgRef{Version=[2],Kind=[Added]}
757 @AddedPragmaSyn<Version=[2],@ChgAdded{Version=[2],Text=`@key{pragma} @prag<Priority_Specific_Dispatching> (@*
758 @ @ @ @ @ @SynI{policy_}@Syn2{identifier}, @SynI{first_priority_}@Syn2{expression}, @SynI{last_priority_}@Syn2{expression});'}>
759
760 @end{Syntax}
761
762 @begin{Resolution}
763
764 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
765 @ChgAdded{Version=[2],Text=[The expected type for @SynI{first_priority_}@nt{expression}
766 and @SynI{last_priority_}@nt{expression} is Integer.]}
767 @end{Resolution}
768
769 @begin{Legality}
770
771 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01],ARef=[AI95-00355-01]}
772 The @SynI{policy_}@nt{identifier} @Chg{Version=[2],New=[used in a @nt{pragma}
773 Task_Dispatching_Policy shall be the name of a task dispatching policy],
774 Old=[shall either be FIFO_Within_Priorities or
775 an implementation-defined @Syn2{identifier}]}.
776 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
777 Text=[@ChgDeleted{Version=[2],
778 Text=[Implementation-defined @SynI{policy_}@Syn2{identifier}s allowed
779 in a @nt{pragma} Task_Dispatching_Policy.]}]}
780
781 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
782 @ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier}
783 used in a @nt{pragma}
784 Priority_Specific_Dispatching shall be the name of a task dispatching policy.]}
785
786 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
787 @ChgAdded{Version=[2],Text=[Both @Syni{first_priority_}@!@nt{expression} and
788 @Syni{last_priority_}@!@nt{expression} shall be static expressions in the range
789 of System.Any_Priority; @SynI{last_priority_}@!@nt{expression} shall have a
790 value greater than or equal to @SynI{first_priority_}@!@nt{expression}.]}
791
792 @end{Legality}
793
794 @begin{StaticSem}
795
796 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
797 @ChgAdded{Version=[2],Text=[@nt{Pragma} Task_Dispatching_Policy specifies the
798 single task dispatching policy.]}
799
800 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
801 @ChgAdded{Version=[2],Text=[@nt{Pragma} Priority_Specific_Dispatching specifies
802 the task dispatching policy for the specified range of priorities. Tasks with
803 base priorities within the range of priorities specified in a
804 Priority_Specific_Dispatching pragma have their active priorities determined
805 according to the specified dispatching policy. Tasks with active priorities
806 within the range of priorities specified in a Priority_Specific_Dispatching
807 pragma are dispatched according to the specified dispatching policy.]}
808 @begin{Reason}
809 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
810 @ChgAdded{Version=[2],Text=[Each ready queue is managed by exactly one
811 policy. Anything else would be chaos. The ready queue is determined by
812 the active priority. However, how the active priority is calculated is
813 determined by the policy; in order to break out of this circle, we have
814 to say that the active priority is calculated by the method determined
815 by the policy of the base priority.]}
816 @end{Reason}
817
818 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
819 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0262-1]}
820 @ChgAdded{Version=[2],Text=[If a partition contains one or more
821 Priority_Specific_Dispatching pragmas@Chg{Version=[3],New=[,],Old=[]}
822 the dispatching policy for priorities not
823 covered by any Priority_Specific_Dispatching pragmas is
824 FIFO_Within_Priorities.]}
825
826 @end{StaticSem}
827
828 @begin{LinkTime}
829
830 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]}
831 @PDefn2{Term=[configuration pragma], Sec=(Task_Dispatching_Policy)}
832 @PDefn2{Term=[pragma, configuration], Sec=(Task_Dispatching_Policy)}
833 A Task_Dispatching_Policy pragma is a configuration pragma.@Chg{Version=[2],
834 New=[ A Priority_Specific_Dispatching pragma is a configuration pragma.
835 @PDefn2{Term=[configuration pragma], Sec=(Priority_Specific_Dispatching)}
836 @PDefn2{Term=[pragma, configuration], Sec=(Priority_Specific_Dispatching)}],Old=[]}
837
838 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
839 @ChgAdded{Version=[2],Text=[The priority ranges specified in more than one
840 Priority_Specific_Dispatching pragma within the same partition shall not be
841 overlapping.]}
842
843 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
844 @ChgAdded{Version=[2],Text=[If a partition contains one or more
845 Priority_Specific_Dispatching pragmas it shall not contain a
846 Task_Dispatching_Policy pragma.]}
847
848 @ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00333-01]}
849 @ChgDeleted{Version=[2],Text=[If the FIFO_Within_Priorities policy is specified
850 for a partition, then the Ceiling_Locking policy
851 (see @RefSecNum{Priority Ceiling Locking}) shall also be specified for
852 the partition.]}
853
854 @end{LinkTime}
855
856 @begin{RunTime}
857
858 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]}
859 @Defn{task dispatching policy}
860 @Redundant[A @i{task dispatching policy} specifies the details of task
861 dispatching that are not covered by the basic task dispatching model.
862 These rules govern when tasks are inserted into and
863 deleted from the ready queues@Chg{Version=[2],New=[],Old=[,
864 and whether a task is inserted at the head or the tail of the
865 queue for its active priority]}.]
866 @Chg{Version=[2],New=[A single],Old=[The]} task dispatching policy is
867 specified by a Task_Dispatching_Policy @Chg{Version=[2],New=[],Old=[configuration ]}pragma.
868 @Chg{Version=[2],New=[Pragma Priority_Specific_Dispatching assigns distinct
869 dispatching policies to subranges of System.Any_Priority.],
870 Old=[@PDefn{unspecified}If no such pragma appears in any of the program
871 units comprising a partition, the task dispatching policy for
872 that partition is unspecified.]}
873
874 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
875 @ChgAdded{Version=[2],Text=[@PDefn{unspecified}If neither @nt{pragma} applies
876 to any of the program units comprising a partition, the task dispatching policy
877 for that partition is unspecified.]}
878
879 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
880 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0262-1]}
881 @ChgAdded{Version=[2],Text=[If a partition contains one or more
882 Priority_Specific_Dispatching pragmas@Chg{Version=[3],New=[,],Old=[]}
883 a task dispatching point occurs for the
884 currently running task of a processor whenever there is a nonempty ready queue
885 for that processor with a higher priority than the priority of the running
886 task.]}
887
888 @begin{Discussion}
889 @ChgRef{Version=[2],Kind=[AddedNormal]}
890 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
891 @ChgAdded{Version=[2],Text=[If we have priority specific dispatching then we
892 want preemption across the entire range of priorities. That prevents higher
893 priority tasks from being blocked by lower priority tasks that have a
894 different policy. On the other hand, if we have a single policy for the
895 entire partition, we want the characteristics of that policy to apply for
896 preemption; specifically, we @Chg{Version=[3],New=[might],Old=[may]}
897 not require any preemption. Note that policy
898 Non_Preemptive_FIFO_Within_Priorities is not allowed in a priority specific
899 dispatching pragma.]}
900 @end{Discussion}
901
902 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00355-01]}
903 @ChgAdded{Version=[2],Text=[A task that has its base priority changed may move
904 from one dispatching policy to another. It is immediately subject
905 to the new dispatching policy.]}
906
907 @begin{Ramification}
908 @ChgRef{Version=[2],Kind=[AddedNormal]}
909 @ChgAdded{Version=[2],Text=[Once subject to the new dispatching policy, it
910 may be immediately preempted or dispatched, according the rules of the new
911 policy.]}
912 @end{Ramification}
913
914 @ChgNote{The following stuff is moved to the next subclause}
915 @begin{NotIso}
916 @ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 7
917 through 13 were moved to D.2.3.>}]}@Comment{This message should be deleted if the
918 paragraphs are ever renumbered.}
919 @end{NotIso}
920
921 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
922 @ChgDeleted{Version=[2],Type=[Leading],Text=[The language defines only one task
923 dispatching policy, FIFO_Within_Priorities; when this policy is in effect,
924 modifications to the ready queues occur only as follows:]}
925
926 @begin{itemize}
927
928 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
929 @ChgDeleted{Version=[2],Text=[When a blocked task becomes ready,
930 it is added at the tail of the ready queue for its active priority.]}
931
932 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
933 @ChgDeleted{Version=[2],Text=[When the active priority of a ready task that is
934 not running changes, or the setting of its base priority takes effect, the task
935 is removed from the ready queue for its old active priority and is added at the
936 tail of the ready queue for its new active priority, except in the case where
937 the active priority is lowered due to the loss of inherited priority, in which
938 case the task is added at the head of the ready queue for its new active
939 priority.]}
940
941 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
942 @ChgDeleted{Version=[2],Text=[When the setting of the base priority of a
943 running task takes effect, the task is added to the tail of the ready queue for
944 its active priority.]}
945
946 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
947 @ChgDeleted{Version=[2],Text=[When a task executes a @nt{delay_statement} that
948 does not result in blocking, it is added to the tail of the ready queue for its
949 active priority.]}
950 @begin{Ramification}
951 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg]}
952 @ChgDeleted{Version=[2],Text=[If the delay does result in blocking,
953 the task moves to the @lquotes@;delay queue@rquotes@;,
954 not to the ready queue.]}
955 @end{Ramification}
956
957 @end{itemize}
958
959 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
960 @ChgDeleted{Version=[2],Text=[@PDefn{task dispatching point}
961 @PDefn{dispatching point}
962 Each of the events specified above is a task dispatching point
963 (see @RefSecNum{The Task Dispatching Model}).]}
964
965 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
966 @ChgDeleted{Version=[2],Text=[In addition, when a task is preempted, it is
967 added at the head of the ready queue for its active priority.]}
968
969 @end{RunTime}
970
971 @begin{ImplReq}
972 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00333-01],ARef=[AI95-00355-01]}
973 @ChgAdded{Version=[2],Text=[An implementation shall allow, for a single
974 partition, both the locking policy (see @RefSecNum{Priority Ceiling Locking})
975 to be specified as Ceiling_Locking
976 and also one or more Priority_Specific_Dispatching pragmas to be given.]}
977 @end{ImplReq}
978
979 @begin{DocReq}
980
981 @begin{NotIso}
982 @ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 14
983 through 16 were moved to D.2.3.>}]}@Comment{This message should be deleted if the
984 paragraphs are ever renumbered.}
985 @end{NotIso}
986 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
987 @ChgDeleted{Version=[2],Type=[Leading],Text=[@Defn{priority inversion}
988 @i{Priority inversion} is the duration for which a task remains at the
989 head of the highest priority ready queue while the processor executes
990 a lower priority task. The implementation shall document:]}
991 @begin{Itemize}
992 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
993 @ChgDeleted{Version=[2],Text=[The maximum priority inversion a user task can experience due to activity
994 of the implementation (on behalf of lower priority tasks), and]}
995
996 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
997 @ChgDeleted{Version=[2],Text=[whether execution of a task can be preempted by
998 the implementation processing of delay
999 expirations for lower priority tasks, and if so, for how long.]}
1000 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
1001 Text=[@ChgDeleted{Version=[2],
1002 Text=[Implementation-defined aspects of priority inversion.]}]}
1003 @end{Itemize}
1004
1005 @end{DocReq}
1006
1007 @begin{ImplPerm}
1008
1009 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]}
1010 Implementations are allowed to define other task dispatching policies, but
1011 need not support more than one @Chg{Version=[2],New=[task dispatching],
1012 Old=[such]} policy per partition.
1013
1014 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]}
1015 @Chg{Version=[2],New=[An implementation need not support @nt{pragma}
1016 Priority_Specific_Dispatching if it is infeasible to support it in the
1017 target environment.],
1018 Old=[@Redundant[For optimization purposes,]
1019 an implementation may alter the points at which task dispatching occurs,
1020 in an implementation defined manner.
1021 However, a @nt{delay_statement} always corresponds to at least one task
1022 dispatching point.]}
1023
1024 @ChgImplDef{Version=[2],Kind=[Revised],InitialVersion=[0],
1025 Text=[Implementation defined task
1026 dispatching@Chg{Version=[2],New=[ policies],Old=[]}.]}
1027
1028 @end{ImplPerm}
1029
1030 @begin{Notes}
1031
1032 @begin{NotIso}
1033 @ChgAdded{Version=[2],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 19
1034 through 21 were deleted.>}]}@Comment{This message should be deleted if the
1035 paragraphs are ever renumbered.}
1036 @end{NotIso}
1037
1038 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
1039 @ChgDeleted{Version=[2],Text=[If the active priority of a running task is
1040 lowered due to loss of inherited priority (as it is on completion of a
1041 protected operation) and there is a ready task of the same active priority that
1042 is not running, the running task continues to run (provided that there is no
1043 higher priority task).]}
1044
1045 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
1046 @ChgDeleted{Version=[2],Text=[The setting of a task's base priority as a result
1047 of a call to Set_Priority does not always take effect immediately when
1048 Set_Priority is called. The effect of setting the task's base priority is
1049 deferred while the affected task performs a protected action.]}
1050
1051 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00321-01]}
1052 @ChgDeleted{Version=[2],Text=[Setting the base priority of a ready task causes
1053 the task to move to the end of the queue for its active priority,
1054 regardless of whether the active priority of the task actually changes.]}
1055
1056 @end{Notes}
1057
1058 @begin{Extend95}
1059 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]}
1060 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1061 @B[Amendment Correction:] It is no longer required to specify Ceiling_Locking
1062 with the language-defined task dispatching policies; we only require that
1063 implementations @i<allow> them to be used together.]}
1064
1065 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1066 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
1067 @ChgAdded{Version=[2],Text=[@key{Pragma} Priority_Specific_Dispatching is
1068 new; it allows @Chg{Version=[3],New=[the specification of],Old=[specifying]}
1069 different policies for different priorities.]}
1070 @end{Extend95}
1071
1072 @begin{DiffWord95}
1073 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]}
1074 @ChgAdded{Version=[2],Text=[Clarified that an implementation need support
1075 only one task dispatching policy (of any kind, language-defined or otherwise)
1076 per partition.]}
1077
1078 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1079 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
1080 @ChgAdded{Version=[2],Text=[This description is simplified to describe only
1081 the rules for the Task_Dispatching_Policy pragma that are common to
1082 all policies. In particular, rules about preemption are moved elsewhere. This
1083 makes it easier to add other policies (which
1084 @Chg{Version=[3],New=[might],Old=[may]} not involve preemption).]}
1085 @end{DiffWord95}
1086
1087
1088 @LabeledAddedSubClause{Version=[2],Name=[Preemptive Dispatching]}
1089
1090 @begin{Intro}
1091 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1092 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
1093 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
1094 defines a preemptive task dispatching policy.]]}
1095 @end{Intro}
1096
1097 @begin{StaticSem}
1098
1099 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1100 @ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier}
1101 FIFO_Within_Priorities is a task dispatching
1102 policy.@Chg{Version=[3],New=[@Defn2{Term=[task dispatching policy],
1103 Sec=(FIFO_Within_Priorities)}@Defn{FIFO_Within_Priorities task dispatching policy}],
1104 Old=[]}]}
1105
1106 @end{StaticSem}
1107
1108 @begin{RunTime}
1109
1110 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1111 @ChgAdded{Version=[2],Text=[When FIFO_Within_Priorities is in effect,
1112 modifications to the ready queues occur only as follows:]}
1113
1114 @begin{itemize}
1115
1116 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1117 @ChgAdded{Version=[2],Text=[When a blocked task becomes ready, it is added at
1118 the tail of the ready queue for its active priority.]}
1119
1120 @ChgRef{Version=[2],Kind=[AddedNormal]}
1121 @ChgAdded{Version=[2],Text=[When the active priority of a ready task that is
1122 not running changes, or the setting of its base
1123 priority takes effect, the task is removed from the ready queue for
1124 its old active priority and is added at the tail of the ready queue for its new
1125 active priority, except in the case where the active priority is lowered due to
1126 the loss of inherited priority, in which case the task is added at the
1127 head of the ready queue for its new active priority.]}
1128
1129 @ChgRef{Version=[2],Kind=[AddedNormal]}
1130 @ChgAdded{Version=[2],Text=[When the setting of the base priority of a running task takes effect, the
1131 task is added to the tail of the ready queue for its active priority.]}
1132
1133 @ChgRef{Version=[2],Kind=[AddedNormal]}
1134 @ChgAdded{Version=[2],Text=[When a task executes a @nt{delay_statement} that
1135 does not result in blocking, it is added to the tail of the ready queue for
1136 its active priority.]}
1137 @begin{Ramification}
1138 @ChgRef{Version=[2],Kind=[AddedNormal]}
1139 @ChgAdded{Version=[2],Text=[If the delay does result in blocking,
1140 the task moves to the @lquotes@;delay queue@rquotes@;,
1141 not to the ready queue.]}
1142 @end{Ramification}
1143
1144 @end{itemize}
1145
1146 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1147 @ChgAdded{Version=[2],Text=[@PDefn{task dispatching point}
1148 @PDefn{dispatching point}
1149 Each of the events specified above is a task dispatching point
1150 (see @RefSecNum{The Task Dispatching Model}).]}
1151
1152 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1153 @ChgAdded{Version=[2],Text=[A task dispatching point occurs for the currently
1154 running task of a processor whenever there is a nonempty ready queue for that
1155 processor with a higher priority than the priority of the running task. The
1156 currently running task is said to be @i<preempted> and it is added at the head
1157 of the ready queue for its active priority.@Defn2{Term=[preempt],Sec=[a running task]}]}
1158
1159 @end{RunTime}
1160
1161 @begin{ImplReq}
1162 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]}
1163 @ChgAdded{Version=[2],Text=[An implementation shall allow, for a single
1164 partition, both the task dispatching policy to be specified as
1165 FIFO_Within_Priorities and also the locking policy (see
1166 @RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]}
1167 @begin{Reason}
1168 @ChgRef{Version=[2],Kind=[AddedNormal]}
1169 @ChgAdded{Version=[2],Text=[This is the preferred combination of the
1170 FIFO_Within_Priorities policy with a locking policy, and we want that
1171 combination to be portable.]}
1172 @end{Reason}
1173 @end{ImplReq}
1174
1175 @begin{DocReq}
1176
1177 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1178 @ChgAdded{Version=[2],Type=[Leading],Text=[@Defn{priority inversion}
1179 @i{Priority inversion} is the duration for which a task remains at the
1180 head of the highest priority nonempty ready queue while the processor executes
1181 a lower priority task. The implementation shall document:]}
1182
1183 @begin{Itemize}
1184 @ChgRef{Version=[2],Kind=[AddedNormal]}
1185 @ChgAdded{Version=[2],Text=[The maximum priority inversion a user task
1186 can experience due to activity
1187 of the implementation (on behalf of lower priority tasks), and]}
1188 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
1189 Text=[The maximum priority inversion a user task can experience from
1190 the implementation.]}]}
1191
1192 @ChgRef{Version=[2],Kind=[AddedNormal]}
1193 @ChgAdded{Version=[2],Text=[whether execution of a task can be preempted
1194 by the implementation processing of delay
1195 expirations for lower priority tasks, and if so, for how long.]}
1196 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
1197 Text=[The amount of time that a task can be preempted for processing on
1198 behalf of lower-priority tasks.]}]}
1199 @end{Itemize}
1200
1201 @end{DocReq}
1202
1203 @begin{Notes}
1204
1205 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1206 @ChgAdded{Version=[2],Text=[If the active priority of a running task is
1207 lowered due to loss of
1208 inherited priority (as it is on completion of a protected
1209 operation) and there is a ready task of the same active priority
1210 that is not running,
1211 the running task continues to run (provided that there is no higher
1212 priority task).]}
1213
1214 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1215 @ChgAdded{Version=[2],Text=[Setting the base priority of a ready task causes
1216 the task to move to the tail of the queue for its active priority,
1217 regardless of whether the active priority of the task actually changes.]}
1218
1219 @end{Notes}
1220
1221 @begin{DiffWord95}
1222 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
1223 @ChgAdded{Version=[2],Text=[This subclause is new; it mainly consists of
1224 text that was found in @RefSecNum{The Task Dispatching Model} and
1225 @RefSecNum{Task Dispatching Pragmas} in Ada 95. This was
1226 separated out so the definition of additional policies was easier.]}
1227
1228 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]}
1229 @ChgAdded{Version=[2],Text=[We require that implementations allow
1230 this policy and Ceiling_Locking together.]}
1231
1232 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1233 @ChgAdded{Version=[2],Text=[We explicitly defined FIFO_Within_Priorities
1234 to be a task dispatching policy.]}
1235 @end{DiffWord95}
1236
1237
1238 @LabeledAddedSubClause{Version=[2],Name=[Non-Preemptive Dispatching]}
1239
1240 @begin{Intro}
1241 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]}
1242 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
1243 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
1244 defines a non-preemptive task dispatching policy.]]}
1245 @end{Intro}
1246
1247 @begin{StaticSem}
1248
1249 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01],ARef=[AI95-00355-01]}
1250 @ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier}
1251 Non_Preemptive_FIFO_Within_Priorities is a task dispatching
1252 policy.@Chg{Version=[3],New=[@Defn2{Term=[task dispatching policy],
1253 Sec=(Non_Preemptive_@!FIFO_@!Within_@!Priorities)}@Defn{Non_Preemptive_FIFO_@!Within_@!Priorities task disp. policy}],
1254 Old=[]}]}
1255
1256 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0166-1]}
1257 @ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The following
1258 language-defined library package exists:]}
1259 @begin{Example}
1260 @ChgRef{Version=[3],Kind=[Added]}
1261 @ChgAdded{Version=[3],Text=[@key<package> Ada.Dispatching.Non_Preemptive @key<is>@ChildUnit{Parent=[Ada.Dispatching],Child=[Non_Preemptive]}
1262 @key<pragma> Preelaborate(Non_Preemptive);
1263 @key<procedure> @AdaSubDefn{Yield_To_Higher};
1264 @key<procedure> @AdaSubDefn{Yield_To_Same_Or_Higher} @key<renames> Yield;
1265 @key<end> Ada.Dispatching.Non_Preemptive;]}
1266 @end{Example}
1267
1268 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0166-1],ARef=[AI05-0264-1]}
1269 @ChgAdded{Version=[3],Text=[A call of Yield_To_Higher is a task dispatching
1270 point for this policy. If the task at the head of the highest priority ready
1271 queue has a higher active priority than the calling task, then the calling task
1272 is preempted.]}
1273
1274 @begin{Ramification}
1275 @ChgRef{Version=[3],Kind=[AddedNormal]}
1276 @ChgAdded{Version=[3],Text=[For language-defined policies other than
1277 Non_Preemptive_FIFO_Within_Priorities, a higher priority task should never be
1278 on a ready queue while a lower priority task is executed. Thus, for such
1279 policies, Yield_To_Higher does nothing.]}
1280
1281 @ChgRef{Version=[3],Kind=[AddedNormal]}
1282 @ChgAdded{Version=[3],Text=[Yield_To_Higher is @i<not> a potentially blocking
1283 operation; it can be used during a protected operation. That is allowed,
1284 as under the predefined Ceiling_Locking policy any
1285 task with a higher priority than the protected operation cannot call the
1286 operation (that would violate the locking policy). An
1287 implementation-defined locking policy may need to define the semantics of
1288 Yield_To_Higher differently.]}
1289 @end{Ramification}
1290 @end{StaticSem}
1291
1292 @begin{Legality}
1293 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1294 @ChgAdded{Version=[2],Text=[Non_Preemptive_FIFO_Within_Priorities shall not be
1295 specified as the @SynI{policy_}@nt{identifier} of @nt{pragma}
1296 Priority_Specific_Dispatching (see
1297 @RefSecNum{Task Dispatching Pragmas}).]}
1298
1299 @begin{Reason}
1300 @ChgRef{Version=[2],Kind=[AddedNormal]}
1301 @ChgAdded{Version=[2],Text=[The non-preemptive nature of this policy could
1302 cause the policies of higher priority tasks to malfunction, missing deadlines
1303 and having unlimited priority inversion. That would render the use of such
1304 policies impotent and misleading. As such, this policy only makes sense
1305 for a complete system.]}
1306 @end{Reason}
1307 @end{Legality}
1308
1309 @begin{RunTime}
1310
1311 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]}
1312 @ChgAdded{Version=[2],Text=[When Non_Preemptive_FIFO_Within_Priorities is in
1313 effect, modifications to the ready queues occur only as follows:]}
1314
1315 @begin{itemize}
1316
1317 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]}
1318 @ChgAdded{Version=[2],Text=[When a blocked task becomes ready, it is added at
1319 the tail of the ready queue for its active priority.]}
1320
1321 @ChgRef{Version=[2],Kind=[AddedNormal]}
1322 @ChgAdded{Version=[2],Text=[When the active priority of a ready task that is
1323 not running changes, or the setting of its base
1324 priority takes effect, the task is removed from the ready queue for
1325 its old active priority and is added at the tail of the ready queue for its new
1326 active priority.]}
1327
1328 @ChgRef{Version=[2],Kind=[AddedNormal]}
1329 @ChgAdded{Version=[2],Text=[When the setting of the base priority of a running task takes effect, the
1330 task is added to the tail of the ready queue for its active priority.]}
1331
1332 @ChgRef{Version=[2],Kind=[AddedNormal]}
1333 @ChgAdded{Version=[2],Text=[When a task executes a @nt{delay_statement} that
1334 does not result in blocking, it is added to the tail of the ready queue for
1335 its active priority.]}
1336 @begin{Ramification}
1337 @ChgRef{Version=[2],Kind=[AddedNormal]}
1338 @ChgAdded{Version=[2],Text=[If the delay does result in blocking,
1339 the task moves to the @lquotes@;delay queue@rquotes@;,
1340 not to the ready queue.]}
1341 @end{Ramification}
1342
1343 @end{itemize}
1344
1345 @ChgRef{Version=[2],Kind=[AddedNormal]}
1346 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0166-1]}
1347 @ChgAdded{Version=[2],Text=[For this policy, @Chg{Version=[3],New=[blocking
1348 or termination of a task, ],Old=[]}a@Chg{Version=[3],New=[],Old=[ non-blocking]}
1349 @nt{delay_statement}@Chg{Version=[3],New=[, a call to Yield_To_Higher, and
1350 a call to Yield_To_Same_Or_Higher or Yield are],Old=[ is]}
1351 the only@Chg{Version=[3],New=[],Old=[ non-blocking event that is a]}
1352 task dispatching @Chg{Version=[3],New=[points],Old=[point]} (see
1353 @RefSecNum{The Task Dispatching Model}).@PDefn{task dispatching point}
1354 @PDefn{dispatching point}]}
1355
1356 @begin{Ramification}
1357 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0166-1]}
1358 @ChgAdded{Version=[3],Text=[A @nt{delay_statement} is always a task
1359 dispatching point even if it is not blocking. Similarly, a call to
1360 Yield_To_Higher is never blocking, but it is a task dispatching point
1361 In each of these cases, they can cause the current task to stop running (it is
1362 still ready). Otherwise, the running task continues to run until it is blocked.]}
1363 @end{Ramification}
1364 @end{RunTime}
1365
1366 @begin{ImplReq}
1367 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01]}
1368 @ChgAdded{Version=[2],Text=[An implementation shall allow, for a single
1369 partition, both the task dispatching policy to be specified as
1370 Non_Preemptive_FIFO_Within_Priorities and also the locking policy (see
1371 @RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]}
1372 @begin{Reason}
1373 @ChgRef{Version=[2],Kind=[AddedNormal]}
1374 @ChgAdded{Version=[2],Text=[This is the preferred combination of the
1375 Non_Preemptive_FIFO_Within_Priorities policy with a locking policy, and we
1376 want that combination to be portable.]}
1377 @end{Reason}
1378 @end{ImplReq}
1379
1380 @begin{ImplPerm}
1381 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01]}
1382 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1],ARef=[AI05-0269-1]}
1383 @ChgAdded{Version=[2],Text=[Since implementations are allowed to round all
1384 ceiling priorities in subrange System.Priority to System.Priority'Last (see
1385 @RefSecNum{Priority Ceiling Locking}), an implementation may allow a
1386 task@Chg{Version=[3],New=[ of a partition using the
1387 Non_Premptive_FIFO_Within_Priorities policy],Old=[]} to
1388 execute within a protected object without raising its active priority provided
1389 the associated protected unit does not contain @Chg{Version=[3],New=[any
1390 subprograms with aspects Interrupt_Handler or Attach_Handler specified, nor
1391 does the unit have aspect],Old=[pragma]} Interrupt_Priority
1392 @Chg{Version=[3],New=[ specified. When the locking policy
1393 (see @RefSecNum{Priority Ceiling Locking}) is
1394 Ceiling_Locking, an implementation taking advantage of this permission shall
1395 ensure that a call to Yield_to_Higher that occurs within a protected action uses
1396 the ceiling priority of the protected object (rather than the active priority of
1397 the task) when determining whether to preempt the task],Old=[,
1398 Interrupt_Handler, or Attach_Handler]}.]}
1399 @begin{Reason}
1400 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0269-1]}
1401 @ChgAdded{Version=[3],Text=[We explicitly require that the ceiling priority be
1402 used in calls to Yield_to_Higher in order to prevent a risk of priority
1403 inversion and consequent loss of mutual exclusion when Yield_to_Higher is used
1404 in a protected object. This requirement might lessen the value of the
1405 permission (as the current Ceiling_Priority will have to be maintained in the
1406 TCB), but loss of mutual exclusion cannot be tolerated. The primary benefit of
1407 the permission (eliminating the need for preemption at the end of a protected
1408 action) is still available. As noted above, an implementation-defined locking
1409 policy will need to specify the semantics of Yield_to_Higher, including this
1410 case.]}
1411 @end{Reason}
1412 @end{ImplPerm}
1413
1414 @begin{Extend95}
1415 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00298-01],ARef=[AI95-00355-01]}
1416 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1417 Policy Non_Preemptive_FIFO_Within_Priorities is new.]}
1418 @end{Extend95}
1419
1420 @begin{Extend2005}
1421 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0166-1]}
1422 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}Package
1423 Dispatching.Non_Preemptive is new.]}
1424 @end{Extend2005}
1425
1426
1427 @RMNewPageVer{Version=[3]}@Comment{For printed RM Ada 2012}
1428 @LabeledAddedSubClause{Version=[2],Name=[Round Robin Dispatching]}
1429
1430 @begin{Intro}
1431 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1432 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
1433 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
1434 defines the task dispatching
1435 policy Round_Robin_Within_Priorities and the package Round_Robin.]]}
1436 @end{Intro}
1437
1438 @begin{StaticSem}
1439
1440 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1441 @ChgAdded{Version=[2],Text=[The @SynI{policy}_@nt{identifier}
1442 Round_Robin_Within_Priorities is a task dispatching
1443 policy.@Chg{Version=[3],New=[@Defn2{Term=[task dispatching policy],
1444 Sec=(Round_Robin_Within_Priorities)}@Defn{Round_Robin_Within_Priorities task dispatching policy}],
1445 Old=[]}]}
1446
1447 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1448 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
1449 language-defined library package exists:]}
1450 @begin{Example}
1451 @ChgRef{Version=[2],Kind=[AddedNormal]}
1452 @ChgAdded{Version=[2],Text=[@key{with} System;
1453 @key{with} Ada.Real_Time;
1454 @key{package} Ada.Dispatching.Round_Robin @key{is}@ChildUnit{Parent=[Ada.Dispatching],Child=[Round_Robin]}
1455 @AdaObjDefn{Default_Quantum} : @key{constant} Ada.Real_Time.Time_Span :=
1456 @RI[implementation-defined];
1457 @key{procedure} @AdaSubDefn{Set_Quantum} (Pri : @key{in} System.Priority;
1458 Quantum : @key{in} Ada.Real_Time.Time_Span);
1459 @key{procedure} @AdaSubDefn{Set_Quantum} (Low, High : @key{in} System.Priority;
1460 Quantum : @key{in} Ada.Real_Time.Time_Span);
1461 @key{function} @AdaSubDefn{Actual_Quantum} (Pri : System.Priority)
1462 @key{return} Ada.Real_Time.Time_Span;
1463 @key{function} @AdaSubDefn{Is_Round_Robin} (Pri : System.Priority) @key{return} Boolean;
1464 @key{end} Ada.Dispatching.Round_Robin;]}
1465 @end{Example}
1466 @ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
1467 Text=[The value of Default_Quantum in Dispatching.Round_Robin.]}]}
1468
1469 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1470 @ChgAdded{Version=[2],Text=[When task dispatching policy Round_Robin_Within_Priorities is the single
1471 policy in effect for a partition, each task with priority in the range of
1472 System.Interrupt_Priority is dispatched according to policy
1473 FIFO_Within_Priorities.]}
1474
1475 @end{StaticSem}
1476
1477 @begin{Runtime}
1478
1479 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1480 @ChgAdded{Version=[2],Text=[The procedures Set_Quantum set the required Quantum
1481 value for a single priority level Pri or a range of priority levels Low .. High.
1482 If no quantum is set for a Round Robin priority level, Default_Quantum is used.]}
1483
1484 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1485 @ChgAdded{Version=[2],Text=[The function Actual_Quantum returns the actual
1486 quantum used by the implementation for the priority level Pri.]}
1487
1488 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1489 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
1490 @ChgAdded{Version=[2],Text=[The function Is_Round_Robin returns True if
1491 priority Pri is covered by task dispatching policy
1492 Round_Robin_Within_Priorities; otherwise@Chg{Version=[3],New=[,],Old=[]}
1493 it returns False.]}
1494
1495 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1496 @ChgAdded{Version=[2],Text=[A call of Actual_Quantum or Set_Quantum raises
1497 exception Dispatching.Dispatching_Policy_Error if a predefined policy other
1498 than Round_Robin_Within_Priorities applies to the specified priority
1499 or any of the priorities in the specified range.]}
1500
1501 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1502 @ChgAdded{Version=[2],Type=[Leading],Text=[For Round_Robin_Within_Priorities,
1503 the dispatching rules for FIFO_Within_Priorities apply with the following
1504 additional rules:]}
1505
1506 @begin{Itemize}
1507
1508 @ChgRef{Version=[2],Kind=[AddedNormal]}
1509 @ChgAdded{Version=[2],Text=[When a task is added or moved to the tail of the
1510 ready queue for its base priority, it has an execution time budget equal to the
1511 quantum for that priority level. This will also occur when a blocked task
1512 becomes executable again.]}
1513
1514 @ChgRef{Version=[2],Kind=[AddedNormal]}
1515 @ChgAdded{Version=[2],Text=[When a task is preempted (by a higher priority
1516 task) and is added to the head of the ready queue for its priority level, it
1517 retains its remaining budget.]}
1518
1519 @ChgRef{Version=[2],Kind=[AddedNormal]}
1520 @ChgAdded{Version=[2],Text=[While a task is executing, its budget is decreased
1521 by the amount of execution time it uses. The accuracy of this accounting is the
1522 same as that for execution time clocks (see @RefSecNum{Execution Time}).]}
1523 @begin{Ramification}
1524 @ChgRef{Version=[2],Kind=[AddedNormal]}
1525 @ChgAdded{Version=[2],Text=[Note that this happens even when the task
1526 is executing at a higher, inherited priority, and even if that higher
1527 priority is dispatched by a different policy than round robin.]}
1528 @end{Ramification}
1529
1530 @ChgRef{Version=[2],Kind=[AddedNormal]}
1531 @ChgAdded{Version=[2],Text=[When a task has exhausted its budget and is without
1532 an inherited priority (and is not executing within a protected operation), it
1533 is moved to the tail of the ready queue for its priority level. This is a task
1534 dispatching point.]}
1535
1536 @begin{Ramification}
1537 @ChgRef{Version=[2],Kind=[AddedNormal]}
1538 @ChgAdded{Version=[2],Text=[In this case, it will be given
1539 a budget as described in the first bullet.]}
1540
1541 @ChgRef{Version=[2],Kind=[AddedNormal]}
1542 @ChgAdded{Version=[2],Text=[The rules for FIFO_Within_Priority (to which
1543 these bullets are added) say that a task that has its base priority set to a
1544 Round Robin priority is moved to the tail of the ready queue for its new
1545 priority level, and then will be given a budget as described in the first
1546 bullet. That happens whether or not the task's original base priority was
1547 a Round Robin priority.]}
1548 @end{Ramification}
1549
1550 @end{Itemize}
1551
1552 @end{Runtime}
1553
1554 @begin{ImplReq}
1555 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00333-01],ARef=[AI95-00355-01]}
1556 @ChgAdded{Version=[2],Text=[An implementation shall allow, for a single
1557 partition, both the task dispatching policy to be specified as
1558 Round_Robin_Within_Priorities and also the locking policy (see
1559 @RefSecNum{Priority Ceiling Locking}) to be specified as Ceiling_Locking.]}
1560 @begin{Reason}
1561 @ChgRef{Version=[2],Kind=[AddedNormal]}
1562 @ChgAdded{Version=[2],Text=[This is the preferred combination of the
1563 Round_Robin_Within_Priorities policy with a locking policy, and we
1564 want that combination to be portable.]}
1565 @end{Reason}
1566 @end{ImplReq}
1567
1568 @begin{DocReq}
1569
1570 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1571 @ChgAdded{Version=[2],Text=[An implementation shall document the quantum values
1572 supported.]}
1573 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
1574 Text=[The quantum values supported for round robin dispatching.]}]}
1575
1576 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1577 @ChgAdded{Version=[2],Text=[An implementation shall document the accuracy with
1578 which it detects the exhaustion of the budget of a task.]}
1579 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
1580 Text=[The accuracy of the detection of the exhaustion of the budget of a task
1581 for round robin dispatching.]}]}
1582
1583 @end{DocReq}
1584
1585 @begin{Notes}
1586
1587 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1588 @ChgAdded{Version=[2],Text=[Due to implementation constraints, the quantum
1589 value returned by Actual_Quantum might not be identical to that set with
1590 Set_Quantum.]}
1591
1592 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1593 @ChgAdded{Version=[2],Text=[A task that executes continuously with an inherited
1594 priority will not be subject to round robin dispatching.]}
1595
1596 @end{Notes}
1597
1598 @begin{Extend95}
1599 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
1600 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1601 Policy Round_Robin_Within_Priorities and package
1602 Dispatching.Round_Robin are new.]}
1603 @end{Extend95}
1604
1605
1606 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
1607 @LabeledAddedSubClause{Version=[2],Name=[Earliest Deadline First Dispatching]}
1608
1609 @begin{Intro}
1610 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1611 @ChgAdded{Version=[2],Text=[The deadline of a task is an indication of the
1612 urgency of the task; it represents a point on an ideal physical time line.
1613 The deadline might affect how resources are allocated to the task.]}
1614
1615 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1616 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1],ARef=[AI05-0299-1]}
1617 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
1618 defines a package for representing the
1619 deadline of a task and a dispatching policy that defines Earliest Deadline
1620 First (EDF) dispatching. @Chg{Version=[3],New=[An aspect],Old=[A pragma]}
1621 is defined to assign an initial deadline to a task.]}
1622
1623 @begin{Discussion}
1624 @ChgRef{Version=[2],Kind=[AddedNormal]}
1625 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1626 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[aspect],Old=[pragma]}
1627 is the only way of assigning an
1628 initial deadline to a task so that its activation can be controlled by EDF
1629 scheduling. This is similar to the way
1630 @Chg{Version=[3],New=[aspect],Old=[pragma]} Priority is used to give an
1631 initial priority to a task.]}
1632 @end{Discussion}
1633
1634 @end{Intro}
1635
1636 @begin{MetaRules}
1637 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1638 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
1639 @ChgAdded{Version=[2],Text=[To predict the behavior of a multi-tasking program
1640 it is necessary to control access to the processor which is preemptive, and
1641 shared objects which are usually non-preemptive and embodied in protected
1642 objects. Two common dispatching policies for the processor are fixed priority
1643 and EDF. The most effective control over shared objects is via preemption
1644 levels. With a pure priority scheme a single notion of priority is used for
1645 processor dispatching and preemption levels. With EDF and similar schemes
1646 priority is used for preemption levels (only), with another measure used for
1647 dispatching. T.P. Baker showed (@i<Real-Time Systems>, March 1991, vol. 3, num.
1648 1, @i<Stack-Based Scheduling of Realtime Processes>) that for EDF a newly
1649 released task should only preempt the currently running task if it has an
1650 earlier deadline and a higher preemption level than any currently
1651 @lquotes@;locked@rquotes protected object. The rules of this
1652 @Chg{Version=[3],New=[subclause],Old=[clause]} implement
1653 this scheme including the case where the newly released task should execute
1654 before some existing tasks but not preempt the currently executing task.]}
1655 @end{MetaRules}
1656
1657 @begin{NotIso}
1658 @ChgAdded{Version=[3],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 3
1659 through 6 were moved to @RefSec{Obsolescent Features}.>}]}@Comment{This message
1660 should be deleted if the paragraphs are ever renumbered.}
1661 @end{NotIso}
1662
1663 @begin{Syntax}
1664
1665 @begin{SyntaxText}
1666 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1667 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
1668 @ChgDeleted{Version=[3],Type=[Leading],Keepnext=[T],Text=[@Chg{Version=[2],New=[The
1669 form of a @nt{pragma} Relative_Deadline is as follows:],Old=[]}]}
1670 @end{SyntaxText}
1671
1672 @ChgRef{Version=[2],Kind=[AddedNormal]}
1673 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1674 @DeletedPragmaSyn<Version=[3],InitialVersion=[2],@ChgDeleted{Version=[3],
1675 Text=`@Chg{Version=[2],New=[@key{pragma} @prag<Relative_Deadline> (@SynI{relative_deadline_}@Syn2{expression});],Old=[]}'}>
1676
1677 @end{Syntax}
1678
1679 @begin{Resolution}
1680
1681 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1682 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
1683 @ChgDeleted{Version=[3],Text=[@Chg{Version=[2],New=[The expected type for
1684 @SynI{relative_deadline_}@nt{expression} is Real_Time.Time_Span.],Old=[]}]}
1685
1686 @end{Resolution}
1687
1688 @begin{Legality}
1689
1690 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1691 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
1692 @ChgDeleted{Version=[3],Text=[@Chg{Version=[2],New=[A Relative_Deadline pragma
1693 is allowed only immediately within a @nt{task_definition} or
1694 the @nt{declarative_part} of a @nt{subprogram_body}. At most one such pragma
1695 shall appear within a given construct.],Old=[]}]}
1696
1697 @end{Legality}
1698
1699 @begin{StaticSem}
1700
1701 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1702 @ChgAdded{Version=[2],Text=[The @SynI{policy_}@nt{identifier}
1703 EDF_Across_Priorities is a task dispatching
1704 policy.@Chg{Version=[3],New=[@Defn2{Term=[task dispatching policy],
1705 Sec=(EDF_Across_Priorities)}@Defn{EDF_Across_Priorities task dispatching policy}],
1706 Old=[]}]}
1707
1708 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1709 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
1710 language-defined library package exists:]}
1711 @begin{Example}
1712 @ChgRef{Version=[2],Kind=[AddedNormal]}
1713 @ChgAdded{Version=[2],Text=[@key{with} Ada.Real_Time;
1714 @key{with} Ada.Task_Identification;
1715 @key{package} Ada.Dispatching.EDF @key{is}@ChildUnit{Parent=[Ada.Dispatching],Child=[EDF]}
1716 @key{subtype} @AdaSubtypeDefn{Name=[Deadline],Of=[Time]} @key{is} Ada.Real_Time.Time;
1717 @AdaObjDefn{Default_Deadline} : @key{constant} Deadline :=
1718 Ada.Real_Time.Time_Last;
1719 @key{procedure} @AdaSubDefn{Set_Deadline} (D : @key{in} Deadline;
1720 T : @key{in} Ada.Task_Identification.Task_Id :=
1721 Ada.Task_Identification.Current_Task);
1722 @key{procedure} @AdaSubDefn{Delay_Until_And_Set_Deadline} (
1723 Delay_Until_Time : @key{in} Ada.Real_Time.Time;
1724 Deadline_Offset : @key{in} Ada.Real_Time.Time_Span);
1725 @key{function} @AdaSubDefn{Get_Deadline} (T : Ada.Task_Identification.Task_Id :=
1726 Ada.Task_Identification.Current_Task) @key{return} Deadline;
1727 @key{end} Ada.Dispatching.EDF;]}
1728 @end{Example}
1729
1730 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
1731 @ChgAdded{Version=[3],Type=[Leading],Text=[For a task type (including the
1732 anonymous type of a @nt{single_task_declaration}) or subprogram, the following
1733 language-defined representation aspect may be specified:]}
1734
1735 @begin{Description}
1736 @ChgRef{Version=[3],Kind=[Added]}
1737 @ChgAdded{Version=[3],Text=[Relative_Deadline@\The aspect
1738 Relative_Deadline is an @nt{expression}, which shall be of
1739 type Real_Time.Time_Span.@AspectDefn{Relative_Deadline}]}
1740
1741 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Relative_Deadline],
1742 Text=[@ChgAdded{Version=[3],Text=[Task parameter used in Earliest Deadline
1743 First Dispatching.]}]}
1744
1745 @end{Description}
1746
1747 @end{StaticSem}
1748
1749 @begin{Legality}
1750 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
1751 @ChgAdded{Version=[3],Text=[The Relative_Deadline aspect shall not be specified
1752 on a task interface type.]}
1753 @end{Legality}
1754
1755 @begin{LinkTime}
1756
1757 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1758 @ChgAdded{Version=[2],Text=[If the EDF_Across_Priorities policy is specified
1759 for a partition, then the Ceiling_Locking policy (see
1760 @RefSecNum{Priority Ceiling Locking}) shall also be
1761 specified for the partition.]}
1762
1763 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1764 @ChgAdded{Version=[2],Text=[If the EDF_Across_Priorities policy appears in a
1765 Priority_Specific_Dispatching pragma
1766 (see @RefSecNum{Task Dispatching Pragmas})
1767 in a partition, then the
1768 Ceiling_Locking policy (see @RefSecNum{Priority Ceiling Locking}) shall also
1769 be specified for the partition.]}
1770
1771 @begin{Reason}
1772 @ChgRef{Version=[2],Kind=[AddedNormal]}
1773 @ChgAdded{Version=[2],Text=[Unlike the other language-defined dispatching
1774 policies, the semantic description of EDF_Across_Priorities assumes
1775 Ceiling_Locking (and a ceiling priority) in order to make the mapping between
1776 deadlines and priorities work. Thus, we require both policies to be specified
1777 if EDF is used in the partition.]}
1778 @end{Reason}
1779
1780 @end{LinkTime}
1781
1782 @begin{RunTime}
1783
1784 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1785 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1786 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[The],Old=[A]}
1787 Relative_Deadline @Chg{Version=[3],New=[aspect],Old=[pragma]} has no effect
1788 if it @Chg{Version=[3],New=[is specified for],
1789 Old=[occurs in the @nt{declarative_part} of the @nt{subprogram_body} of]} a
1790 subprogram other than the main subprogram.]}
1791
1792 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1793 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1794 @ChgAdded{Version=[2],Text=[The initial absolute deadline of a task
1795 @Chg{Version=[3],New=[for which aspect],Old=[containing
1796 pragma]} Relative_Deadline@Chg{Version=[3],New=[ is specified],Old=[]} is
1797 the value of Real_Time.Clock +
1798 @Chg{Version=[3],New=[the @nt{expression} that is the value of the
1799 aspect],Old=[@SynI{relative_deadline_}@nt{expression}]}, where
1800 @Chg{Version=[3],New=[this entire expression, including ],Old=[]}the
1801 call of Real_Time.Clock@Chg{Version=[3],New=[, is evaluated],Old=[ is made]}
1802 between task creation and the start of its activation. If
1803 @Chg{Version=[3],New=[the aspect],Old=[there is no]}
1804 Relative_Deadline @Chg{Version=[3],New=[is not specified,],Old=[pragma]}
1805 then the initial absolute deadline of a task is the
1806 value of Default_Deadline. The environment task is also given
1807 an initial deadline by this rule@Chg{Version=[3],New=[, using the value of
1808 the Relative_Deadline aspect of the main subprogram (if any)],Old=[]}.]}
1809
1810 @begin{TheProof}
1811 @ChgRef{Version=[2],Kind=[AddedNormal]}
1812 @ChgAdded{Version=[2],Text=[The environment task is a normal task by
1813 @RefSecNum{Program Execution}, so of course this rule applies to it.]}
1814 @end{TheProof}
1815
1816 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1817 @ChgAdded{Version=[2],Text=[The procedure Set_Deadline changes the absolute
1818 deadline of the task to D. The function Get_Deadline returns the absolute
1819 deadline of the task.]}
1820
1821 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1822 @ChgAdded{Version=[2],Text=[The procedure Delay_Until_And_Set_Deadline delays
1823 the calling task until time Delay_Until_Time. When the task becomes runnable
1824 again it will have deadline Delay_Until_Time + Deadline_Offset.]}
1825
1826 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1827 @ChgAdded{Version=[2],Text=[On a system with a single processor, the setting of
1828 the deadline of a task to the new value occurs immediately at the first point
1829 that is outside the execution of a protected action. If the task is currently
1830 on a ready queue it is removed and re-entered on to the ready queue determined
1831 by the rules defined below.]}
1832
1833 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1834 @ChgAdded{Version=[2],Text=[When EDF_Across_Priorities is specified for
1835 priority range @i<Low>..@i<High> all ready queues in this range are ordered by
1836 deadline. The task at the head of a queue is the one with the earliest
1837 deadline.]}
1838
1839 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1840 @ChgAdded{Version=[2],Type=[Leading],Text=[A task dispatching point occurs
1841 for the currently running task @i<T> to
1842 which policy EDF_Across_Priorities applies:]}
1843
1844 @begin{Itemize}
1845
1846 @ChgRef{Version=[2],Kind=[AddedNormal]}
1847 @ChgAdded{Version=[2],Text=[when a change to the deadline of @i<T> occurs;]}
1848
1849 @ChgRef{Version=[2],Kind=[AddedNormal]}
1850 @ChgAdded{Version=[2],Text=[there is a task on the ready queue for the
1851 active priority of @i<T> with a deadline earlier than the deadline of @i<T>; or]}
1852
1853 @ChgRef{Version=[2],Kind=[AddedNormal]}
1854 @ChgAdded{Version=[2],Text=[there is a nonempty ready queue for that processor
1855 with a higher priority than the active priority of the running task.]}
1856
1857 @end{Itemize}
1858
1859 @ChgRef{Version=[2],Kind=[AddedNormal]}
1860 @ChgAdded{Version=[2],Text=[In these cases, the currently running task is said
1861 to be preempted and is returned to
1862 the ready queue for its active priority.]}
1863
1864 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1865 @ChgAdded{Version=[2],Type=[Leading],Text=[For a task @i<T> to which policy
1866 EDF_Across_Priorities applies, the base priority is not a source of
1867 priority inheritance; the active priority when first activated or
1868 while it is blocked is defined as the maximum of the following:]}
1869
1870 @begin{Itemize}
1871 @ChgRef{Version=[2],Kind=[AddedNormal]}
1872 @ChgAdded{Version=[2],Text=[the lowest priority in the range specified as
1873 EDF_Across_Priorities that includes the base priority of @i<T>;]}
1874
1875 @ChgRef{Version=[2],Kind=[AddedNormal]}
1876 @ChgAdded{Version=[2],Text=[the priorities, if any, currently inherited by
1877 @i<T>;]}
1878
1879 @ChgRef{Version=[2],Kind=[AddedNormal]}
1880 @ChgRef{Version=[3],Kind=[Revised], ARef=[AI05-0055-1]}
1881 @ChgAdded{Version=[2],Text=[the highest priority @i<P>, if any, less than the
1882 base priority of @i<T> such that one or more tasks are executing within a
1883 protected object with ceiling priority @i<P> and task @i<T>
1884 has an earlier deadline than all such tasks@Chg{Version=[3],New=[;
1885 and furthermore @i<T> has an earlier deadline than all other tasks on
1886 ready queues with priorities in the given EDF_Across_Priorities range that
1887 are strictly less than @i<P>],Old=[]}.]}
1888 @end{Itemize}
1889
1890 @begin{Ramification}
1891 @ChgRef{Version=[2],Kind=[AddedNormal]}
1892 @ChgAdded{Version=[2],Text=[The active priority of @i<T> might be lower than
1893 its base priority.]}
1894 @end{Ramification}
1895
1896 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1897 @ChgAdded{Version=[2],Text=[When a task @i<T> is first activated or becomes
1898 unblocked, it is added to the ready queue corresponding to this active
1899 priority. Until it becomes blocked again, the active priority of @i<T>
1900 remains no less than this value; it will exceed this value only while it is
1901 inheriting a higher priority.]}
1902
1903 @begin{Discussion}
1904 @ChgRef{Version=[2],Kind=[AddedNormal]}
1905 @ChgAdded{Version=[2],Text=[These rules ensure that a task executing in
1906 a protected object is preempted only by a task with a shorter deadline and a
1907 higher base priority. This matches the traditional preemption level
1908 description without the need to define a new kind of protected object
1909 locking.]}
1910 @end{Discussion}
1911
1912 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1913 @ChgAdded{Version=[2],Text=[When the setting of the base priority of a ready
1914 task takes effect and the new priority is in a range specified as
1915 EDF_Across_Priorities, the task is added to the ready queue
1916 corresponding to its new active priority, as determined above.]}
1917
1918 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1919 @ChgAdded{Version=[2],Text=[For all the operations defined in Dispatching.EDF,
1920 Tasking_Error is raised if the task identified by T has terminated.
1921 Program_Error is raised if the value of T is Null_Task_Id.]}
1922
1923 @end{RunTime}
1924
1925 @begin{Bounded}
1926
1927 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1928 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
1929 If EDF_Across_Priorities is specified for priority range @i<Low>..@i<High>, it
1930 is a bounded error to declare a protected object with ceiling priority
1931 @i<Low> or to assign the value @i<Low> to attribute 'Priority. In either case
1932 either Program_Error is raised or the ceiling of the protected
1933 object is assigned the value @i<Low>+1.]}
1934
1935 @end{Bounded}
1936
1937 @begin{Erron}
1938
1939 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1940 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)}
1941 If a value of Task_Id is passed as a parameter to any of the subprograms
1942 of this package and the corresponding task object no longer exists,
1943 the execution of the program is erroneous.]}
1944
1945 @end{Erron}
1946
1947 @begin{DocReq}
1948
1949 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1950 @ChgAdded{Version=[2],Text=[On a multiprocessor, the implementation shall
1951 document any conditions that cause the completion of the setting of the deadline
1952 of a task to be delayed later than what is specified for a single processor.]}
1953 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
1954 Text=[Any conditions that cause the completion of the setting of the deadline
1955 of a task to be delayed for a multiprocessor.]}]}
1956 @end{DocReq}
1957
1958 @begin{Notes}
1959 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1960 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
1961 @ChgAdded{Version=[2],Text=[If two adjacent priority ranges, @i<A>..@i<B> and
1962 @i<B>+1..@i<C> are specified to have policy
1963 EDF_Across_Priorities@Chg{Version=[3],New=[,],Old=[]} then
1964 this is not equivalent to this policy being
1965 specified for the single range, @i<A>..@i<C>.]}
1966
1967 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1968 @ChgAdded{Version=[2],Text=[The above rules implement the preemption-level
1969 protocol (also called Stack Resource Policy protocol) for resource sharing
1970 under EDF dispatching. The preemption-level for a task is denoted by its base
1971 priority. The definition of a ceiling preemption-level for a protected object
1972 follows the existing rules for ceiling locking.]}
1973
1974 @begin{ImplNote}
1975 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1976 @ChgAdded{Version=[2],Text=[An implementation may support additional
1977 dispatching policies by replacing absolute deadline with an alternative
1978 measure of urgency.]}
1979 @end{ImplNote}
1980
1981 @end{Notes}
1982
1983 @begin{Extend95}
1984 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
1985 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1986 Policy EDF_Across_Priorities and package Dispatching.EDF are new.]}
1987 @end{Extend95}
1988
1989 @begin{Extend2005}
1990 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
1991 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
1992 Aspect Relative_Deadline is new; @nt{pragma} Relative_Deadline
1993 is now obsolescent.]}
1994 @end{Extend2005}
1995
1996 @begin{Diffword2005}
1997 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0055-1]}
1998 @ChgAdded{Version=[3],Text=[@b<Correction:> Corrected definition
1999 of active priority to avoid deadline inversion in an unusual case.]}
2000 @end{Diffword2005}
2001
2002
2003 @LabeledClause{Priority Ceiling Locking}
2004
2005 @begin{Intro}
2006 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2007 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
2008 the interactions between priority task
2009 scheduling and protected object ceilings. This interaction is based on
2010 the concept of the @i{ceiling priority} of a protected object.]
2011 @end{Intro}
2012
2013 @begin{Syntax}
2014 @begin{SyntaxText}
2015 @Leading@Keepnext@;The form of a @nt{pragma} Locking_Policy is as follows:
2016 @end{SyntaxText}
2017
2018 @PragmaSyn`@key{pragma} @prag(Locking_Policy)(@SynI{policy_}@Syn2{identifier});'
2019 @end{Syntax}
2020
2021 @begin{Legality}
2022
2023 The @SynI{policy_}@Syn2{identifier} shall either be Ceiling_Locking
2024 or an implementation-defined @Syn2{identifier}.
2025 @ImplDef{Implementation-defined @SynI{policy_}@Syn2{identifier}s allowed
2026 in a @nt{pragma} Locking_Policy.}
2027
2028 @end{Legality}
2029
2030 @begin{LinkTime}
2031
2032 @PDefn2{Term=[configuration pragma], Sec=(Locking_Policy)}
2033 @PDefn2{Term=[pragma, configuration], Sec=(Locking_Policy)}
2034 A Locking_Policy pragma is a configuration pragma.
2035
2036 @end{LinkTime}
2037
2038 @begin{RunTime}
2039
2040 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0073],ARef=[AI95-00091-01]}
2041 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
2042 @Defn{locking policy}
2043 @Redundant[A locking policy specifies the details of protected object
2044 locking. @Chg{Version=[2],New=[All protected objects have a priority.
2045 The locking policy specifies the meaning of
2046 the priority of a],Old=[These rules specify whether or not]} protected @Chg{Version=[2],
2047 New=[object],Old=[objects have
2048 priorities]}, and the relationships between these priorities and
2049 task priorities. In addition, the policy specifies the state of a task
2050 when it executes a protected action, and how its active priority is
2051 affected by the locking.]
2052 The @i{locking policy} is specified by a Locking_Policy pragma. For
2053 implementation-defined locking policies, the @Chg{Version=[2],New=[meaning of
2054 the priority of],Old=[effect of a Priority or
2055 Interrupt_Priority pragma on]} a protected object is
2056 implementation defined.
2057 If no Locking_Policy pragma @Chg{New=[applies to],Old=[appears in]} any
2058 of the program units comprising a partition, the locking policy for that
2059 partition, as well as the @Chg{Version=[2],New=[meaning of
2060 the priority of],Old=[effect of specifying either a Priority or
2061 Interrupt_Priority pragma for]} a protected object, are implementation defined.
2062 @Chg{Version=[2],New=[@Defn2{Term=[Priority],Sec=[of a protected object]}],Old=[]}
2063
2064 @ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2065 Text=[The locking policy if no Locking_Policy pragma applies to any unit of
2066 a partition.]}]}
2067
2068 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00327-01]}
2069 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0229-1]}
2070 @ChgAdded{Version=[2],Text=[The @nt{expression} @Chg{Version=[3],New=[specified
2071 for the],Old=[of a]} Priority or Interrupt_Priority
2072 @Chg{Version=[3],New=[aspect],Old=[pragma]}
2073 (see @RefSecNum{Task Priorities}) is evaluated as part of the creation
2074 of the corresponding
2075 protected object and converted to the subtype System.Any_Priority or
2076 System.Interrupt_Priority, respectively. The value of the expression is the
2077 initial priority of the corresponding protected object. If no Priority or
2078 Interrupt_Priority @Chg{Version=[3],New=[aspect is specified for],Old=[pragma
2079 applies to]} a protected object, the initial priority
2080 is specified by the locking policy.
2081 @Chg{Version=[3],New=[@PDefn2{Term=[implicit subtype conversion],Sec=(Priority aspect)}
2082 @PDefn2{Term=[implicit subtype conversion],Sec=(Interrupt_Priority aspect)}],
2083 Old=[@PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)}
2084 @PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)}]}]}
2085
2086 @Leading@;There is one predefined locking policy, Ceiling_Locking; this policy is
2087 defined as follows:@Chg{Version=[3],New=[@Defn2{Term=[locking policy],
2088 Sec=(Ceiling_Locking)}@Defn{Ceiling_Locking locking policy}],
2089 Old=[]}
2090 @begin{itemize}
2091
2092 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
2093 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
2094 @Defn2{Term=[ceiling priority], Sec=(of a protected object)}
2095 Every protected object has a @i{ceiling priority}, which
2096 is determined by either a Priority or Interrupt_Priority
2097 @Chg{Version=[3],New=[aspect],Old=[pragma]} as
2098 defined in @RefSecNum{Task Priorities}@Chg{Version=[2],New=[, or by
2099 assignment to the Priority attribute as described
2100 in @RefSecNum{Dynamic Priorities for Protected Objects}],Old=[]}.
2101 The ceiling priority of a protected object (or ceiling, for short) is an
2102 upper bound on the active priority a task can have when
2103 it calls protected operations of that protected object.
2104
2105 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
2106 The @Chg{Version=[2],New=[initial ceiling priority of a],Old=[@nt{expression}
2107 of a Priority or Interrupt_Priority pragma is evaluated as part of the creation of the corresponding]}
2108 protected object
2109 @Chg{Version=[2],New=[is
2110 equal to the initial priority for that object.],Old=[and converted
2111 to the subtype System.Any_Priority or System.Interrupt_Priority, respectively.
2112 The value of the @nt{expression} is the ceiling priority of
2113 the corresponding protected object.
2114 @PDefn2{Term=[implicit subtype conversion],Sec=(pragma Priority)}
2115 @PDefn2{Term=[implicit subtype conversion],Sec=(pragma Interrupt_Priority)}]}
2116
2117 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
2118 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
2119 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0051-1]}
2120 If an Interrupt_Handler or Attach_Handler @Chg{Version=[3],New=[aspect],
2121 Old=[pragma]} (see @RefSecNum{Protected Procedure Handlers})
2122 @Chg{Version=[3],New=[is specified for a protected subprogram of a
2123 protected type that does not have @Chg{Version=[4],New=[either ],Old=[]}the
2124 ],Old=[appears in a @nt{protected_definition} without an]}
2125 @Chg{Version=[4],New=[Priority or ],Old=[]}Interrupt_Priority
2126 @Chg{Version=[3],New=[aspect specified],Old=[pragma]}, the
2127 @Chg{Version=[2],New=[initial],Old=[ceiling]} priority of protected objects
2128 of that type is implementation defined,
2129 but in the range of the subtype System.Interrupt_Priority.
2130 @ImplDef{Default ceiling priorities.}
2131
2132 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
2133 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
2134 If @Chg{Version=[3],New=[neither aspect],Old=[no @nt{pragma}]}
2135 Priority@Chg{Version=[3],New=[ nor],Old=[,]}
2136 Interrupt_Priority@Chg{Version=[3],New=[],Old=[, Interrupt_Handler,
2137 or Attach_Handler]} is specified
2138 @Chg{Version=[3],New=[for a protected type, and no protected subprogram
2139 of the type has aspect Interrupt_Handler or
2140 Attach_Handler specified],Old=[in the
2141 @nt{protected_definition}]}, then the
2142 @Chg{Version=[2],New=[initial],Old=[ceiling]} priority of the corresponding
2143 protected object is System.Priority'Last.
2144
2145 While a task executes a protected action, it inherits the ceiling
2146 priority of the corresponding protected object.
2147
2148 @IndexCheck{Ceiling_Check}
2149 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
2150 When a task calls a protected operation, a check is made that its active
2151 priority is not higher than the ceiling of the corresponding protected object;
2152 Program_Error is raised if this check fails.
2153
2154 @end{Itemize}
2155
2156 @end{RunTime}
2157
2158 @begin{Bounded}
2159 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00327-01]}
2160 @ChgAdded{Version=[2],Type=[Leading],Text=[Following any change of priority,
2161 it is a bounded error for the active priority of any task with a call queued on
2162 an entry of a protected object to be higher than the ceiling priority of the
2163 protected object.
2164 @PDefn2{Term=(bounded error),Sec=(cause)}
2165 In this case one of the following applies:]}
2166
2167 @begin{Itemize}
2168
2169 @ChgRef{Version=[2],Kind=[Added]}
2170 @ChgAdded{Version=[2],Text=[at any time prior to executing the entry body
2171 Program_Error is raised in the calling task;
2172 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
2173
2174 @ChgRef{Version=[2],Kind=[Added]}
2175 @ChgAdded{Version=[2],Text=[when the entry is open the entry body is executed
2176 at the ceiling priority of the protected object;]}
2177
2178 @ChgRef{Version=[2],Kind=[Added]}
2179 @ChgAdded{Version=[2],Text=[when the entry is open the entry body is executed
2180 at the ceiling priority of the protected object and then Program_Error is
2181 raised in the calling task; or
2182 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
2183
2184 @ChgRef{Version=[2],Kind=[Added]}
2185 @ChgAdded{Version=[2],Text=[when the entry is open the entry body
2186 is executed at the ceiling priority of the protected object that was in effect
2187 when the entry call was queued.]}
2188 @end{Itemize}
2189 @begin{Ramification}
2190 @ChgRef{Version=[2],Kind=[Added]}@Comment{This note was moved along with the above rules}
2191 @ChgAdded{Version=[2],Text=[Note that the error is @lquotes@;blamed@rquotes@;
2192 on the task that did the entry call, not the task that changed the
2193 priority of the task or protected object.
2194 This seems to make sense for the case of changing the priority of a task
2195 blocked on a call, since if the Set_Priority had happened a
2196 little bit sooner, before the task queued a call,
2197 the entry-calling task would get the error.
2198 Similarly, there is no reason not to raise the priority of a
2199 task that is executing in an @nt{abortable_part}, so long as its
2200 priority is lowered before it gets to the end and needs to cancel the
2201 call.
2202 The priority might need to be lowered to allow it to remove the call
2203 from the entry queue,
2204 in order to avoid violating the ceiling.
2205 This seems relatively harmless, since there is an error,
2206 and the task is about to start raising an exception anyway.]}
2207 @end{Ramification}
2208 @end{Bounded}
2209
2210 @begin{ImplPerm}
2211
2212 The implementation is allowed to round all ceilings in a certain
2213 subrange of System.Priority or System.Interrupt_Priority up to
2214 the top of that subrange, uniformly.
2215 @begin{Discussion}
2216 For example, an implementation might use Priority'Last for all ceilings
2217 in Priority, and Interrupt_Priority'Last for all ceilings in
2218 Interrupt_Priority.
2219 This would be equivalent to having two ceiling priorities for protected objects,
2220 @lquotes@;nonpreemptible@rquotes@; and @lquotes@;noninterruptible@rquotes@;, and is an allowed behavior.
2221
2222 Note that the implementation cannot choose a subrange that crosses the
2223 boundary between normal and interrupt priorities.
2224 @end{Discussion}
2225
2226 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]}
2227 Implementations are allowed to define other locking policies,
2228 but need not support more than one @Chg{Version=[2],New=[locking],Old=[such]}
2229 policy per partition.
2230
2231 @Redundant[Since implementations are allowed to place restrictions
2232 on code that runs at an interrupt-level active priority
2233 (see @RefSecNum{Protected Procedure Handlers}
2234 and @RefSecNum{The Task Dispatching Model}),
2235 the implementation may implement a language feature in terms
2236 of a protected object with an implementation-defined ceiling,
2237 but the ceiling shall be no less than Priority'Last.]
2238 @ImplDef{The ceiling of any protected object used internally by the
2239 implementation.}
2240 @begin{TheProof}
2241 This permission follows from the fact that
2242 the implementation can place restrictions on interrupt
2243 handlers and on any other code that runs at an interrupt-level
2244 active priority.
2245
2246 The implementation might protect a storage pool with a
2247 protected object whose ceiling is Priority'Last, which would cause
2248 @nt{allocator}s to fail when evaluated at interrupt priority.
2249 Note that the ceiling of such an object has to be at least
2250 Priority'Last,
2251 since there is no permission for @nt{allocator}s to fail when evaluated at
2252 a noninterrupt priority.
2253 @end{TheProof}
2254
2255 @end{ImplPerm}
2256
2257 @begin{ImplAdvice}
2258
2259 The implementation should use names that end with
2260 @lquotes@;_Locking@rquotes@; for implementation-defined locking policies.
2261
2262 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2263 Text=[Names that end with @lquotes@;_Locking@rquotes@; should be used for
2264 implementation-defined locking policies.]}]}
2265
2266 @end{ImplAdvice}
2267
2268 @begin{Notes}
2269
2270 While a task executes in a protected action, it can be preempted
2271 only by tasks whose active priorities are higher than the
2272 ceiling priority of the protected object.
2273
2274 If a protected object has a ceiling priority in the range
2275 of Interrupt_Priority, certain interrupts are blocked while
2276 protected actions of that object execute. In the extreme, if
2277 the ceiling is Interrupt_Priority'Last, all blockable interrupts
2278 are blocked during that time.
2279
2280 The ceiling priority of a protected object has to be in the
2281 Interrupt_Priority range if one of its procedures is to be used as
2282 an interrupt handler (see @RefSecNum{Interrupt Support}).
2283
2284 When specifying the ceiling of a protected object, one should
2285 choose a value that is at least as high as the highest active priority
2286 at which tasks can be executing when they call
2287 protected operations of that object. In determining this
2288 value the following factors, which can affect active priority,
2289 should be considered: the effect of Set_Priority, nested
2290 protected operations, entry calls, task activation, and other
2291 implementation-defined factors.
2292
2293 Attaching a protected procedure whose ceiling is below the
2294 interrupt hardware priority to an interrupt causes the execution of the
2295 program to be erroneous
2296 (see @RefSecNum{Protected Procedure Handlers}).
2297
2298 On a single processor implementation, the ceiling priority
2299 rules guarantee that there is no possibility of deadlock involving
2300 only protected subprograms (excluding the case where a protected operation
2301 calls another protected operation on the same protected object).
2302
2303 @end{Notes}
2304
2305 @begin{Extend95}
2306 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2307 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
2308 All protected objects now have a priority, which
2309 is the value of the Priority attribute of
2310 @RefSecNum{Dynamic Priorities for Protected Objects}. How this value
2311 is interpreted depends on the locking policy; for instance, the ceiling
2312 priority is derived from this value when the locking policy is
2313 Ceiling_Locking.]}
2314 @end{Extend95}
2315
2316 @begin{DiffWord95}
2317 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0073],ARef=[AI95-00091-01]}
2318 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the wording to
2319 reflect that pragma Locking_Policy cannot be inside of a program unit.]}
2320
2321 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]}
2322 @ChgAdded{Version=[2],Text=[Clarified that an implementation need support
2323 only one locking policy (of any kind, language-defined or otherwise)
2324 per partition.]}
2325
2326 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2327 @ChgAdded{Version=[2],Text=[The bounded error for the priority of a task
2328 being higher than the ceiling of an object it is currently in was moved here
2329 from @RefSecNum{Dynamic Priorities}, so that it applies no matter how the
2330 situation arises.]}
2331 @end{DiffWord95}
2332
2333 @begin{DiffWord2005}
2334 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
2335 @ChgAdded{Version=[3],Text=[Revised to use aspects Priority and
2336 Interrupt_Priority as @nt{pragma}s
2337 Priority and Interrupt_Priority are now obsolescent.]}
2338 @end{DiffWord2005}
2339
2340 @begin{DiffWord2012}
2341 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0051-1]}
2342 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that the Priority
2343 aspect can be used to set the initial ceiling priority of a protected object
2344 that contains an interrupt handler.]}
2345 @end{DiffWord2012}
2346
2347
2348 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
2349 @LabeledClause{Entry Queuing Policies}
2350
2351 @begin{Intro}
2352 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0074],ARef=[AI95-00068-01]}
2353 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2354 @Redundant[@Defn{queuing policy}
2355 This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
2356 a mechanism for a user to choose an entry
2357 @i{queuing policy}. It also defines @Chg{New=[two],Old=[one]}
2358 such polic@Chg{New=[ies],Old=[y]}. Other policies are implementation defined.]
2359 @ImplDef{Implementation-defined queuing policies.}
2360 @end{Intro}
2361
2362 @begin{Syntax}
2363 @begin{SyntaxText}
2364 @Leading@Keepnext@;The form of a @nt{pragma} Queuing_Policy is as follows:
2365 @end{SyntaxText}
2366
2367 @PragmaSyn`@key{pragma} @prag(Queuing_Policy)(@SynI{policy_}@Syn2{identifier});'
2368 @end{Syntax}
2369
2370 @begin{Legality}
2371
2372 The @SynI{policy_}@Syn2{identifier} shall be either FIFO_Queuing,
2373 Priority_Queuing or an implementation-defined @Syn2{identifier}.
2374
2375 @end{Legality}
2376
2377 @begin{LinkTime}
2378
2379 @PDefn2{Term=[configuration pragma], Sec=(Queuing_Policy)}
2380 @PDefn2{Term=[pragma, configuration], Sec=(Queuing_Policy)}
2381 A Queuing_Policy pragma is a configuration pragma.
2382
2383 @end{LinkTime}
2384
2385 @begin{RunTime}
2386
2387 @Defn{queuing policy}
2388 @Redundant[A @i{queuing policy} governs the order in which tasks are queued
2389 for entry service, and the order in which different entry queues are
2390 considered for service.]
2391 The queuing policy is specified by a Queuing_Policy pragma.
2392 @begin{Ramification}
2393 The queuing policy includes entry queuing order,
2394 the choice among open alternatives of a @nt{selective_accept},
2395 and the choice among queued entry calls of
2396 a protected object when more than one @nt{entry_barrier} @nt{condition} is True.
2397 @end{Ramification}
2398
2399 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00355-01]}
2400 Two queuing policies, FIFO_Queuing and Priority_Queuing,
2401 are language defined. If no Queuing_Policy pragma
2402 @Chg{Version=[2],New=[applies to],Old=[appears in]} any of the program units
2403 comprising the partition, the queuing policy for that partition
2404 is FIFO_Queuing.@Chg{Version=[3],New=[@Defn2{Term=[queuing policy],
2405 Sec=(FIFO_Queuing)}@Defn{FIFO_Queuing queuing policy}],
2406 Old=[]} The rules for this policy are specified in
2407 @RefSecNum{Entry Calls} and @RefSecNum{Selective Accept}.
2408
2409 @Leading@Keepnext@;The Priority_Queuing policy is defined as
2410 follows:@Chg{Version=[3],New=[@Defn2{Term=[queuing policy],
2411 Sec=(Priority_Queuing)}@Defn{Priority_Queuing queuing policy}],
2412 Old=[]}@begin{itemize}
2413
2414 @Defn{priority of an entry call}
2415 The calls to an entry @Redundant[(including a member of an entry family)]
2416 are queued in an order consistent with the priorities of the calls. The
2417 @i{priority of an entry call} is initialized from the active
2418 priority of the calling task at the time
2419 the call is made, but can change later. Within the same priority,
2420 the order is consistent with the calling (or requeuing,
2421 or priority setting) time (that is, a FIFO order).
2422
2423 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0075],ARef=[AI95-00205-01]}
2424 After a call is first queued, changes to the active priority of a task do
2425 not affect the priority of the call, unless the base priority of the task is
2426 set@Chg{New=[ while the task is blocked on an entry call],Old=[]}.
2427
2428 When the base priority of a task is set (see @RefSecNum{Dynamic Priorities}),
2429 if the task is blocked on an entry call, and the call is queued,
2430 the priority of the call is updated to the new active priority of the
2431 calling task. This causes the call to be removed from and then reinserted in
2432 the queue at the new active priority.
2433 @begin{Reason}
2434 A task is blocked on an entry call if the entry call is simple,
2435 conditional, or timed.
2436 If the call came from the @nt{triggering_statement} of an
2437 @nt{asynchronous_select}, or a requeue thereof,
2438 then the task is not blocked on that call;
2439 such calls do not have their priority updated.
2440 Thus, there can exist many queued calls from a given task
2441 (caused by many nested ATC's),
2442 but a task can be blocked on only one call at a time.
2443
2444 A previous version of Ada 9X required queue reordering in the
2445 @nt{asynchronous_select} case as well.
2446 If the call corresponds to a @lquotes@;synchronous@rquotes@; entry call, then the task
2447 is blocked while queued, and it makes good sense to move it up in the
2448 queue if its priority is raised.
2449
2450 However, if the entry call is @lquotes@;asynchronous,@rquotes@; that is, it is
2451 due to an @nt{asynchronous_select} whose @nt{triggering_statement}
2452 is an entry call, then the task is not waiting for this
2453 entry call, so the placement of the entry call on the
2454 queue is irrelevant to the rate at which the task proceeds.
2455
2456 Furthermore, when an entry is used for @nt{asynchronous_select}s,
2457 it is almost certain to be a @lquotes@;broadcast@rquotes@; entry or have
2458 only one caller at a time. For example, if the entry is
2459 used to notify tasks of a mode switch, then all tasks on the
2460 entry queue would be signaled when the mode changes. Similarly,
2461 if it is indicating some interrupting event such as a control-C,
2462 all tasks sensitive to the interrupt will want to be informed
2463 that the event occurred. Hence, the order on such a queue is
2464 essentially irrelevant.
2465
2466 Given the above, it seems an unnecessary semantic and implementation
2467 complexity to specify that asynchronous queued calls are moved in
2468 response to dynamic priority changes. Furthermore, it is somewhat
2469 inconsistent, since the call was originally queued based on the active
2470 priority of the task, but dynamic priority changes are changing the base
2471 priority of the task, and only indirectly the active priority. We say
2472 explicitly that asynchronous queued calls are not affected by normal
2473 changes in active priority during the execution of an
2474 @nt{abortable_part}. Saying that, if a change in the base priority
2475 affects the active priority, then we do want the calls reordered, would
2476 be inconsistent.
2477 It would also require the implementation to maintain a readily
2478 accessible list of all queued calls which would not otherwise be
2479 necessary.
2480
2481 Several rules were removed or simplified when we changed the rules so
2482 that calls due to @nt{asynchronous_select}s are never moved due to
2483 intervening changes in active priority, be they due to protected
2484 actions, some other priority inheritance, or changes in the base
2485 priority.
2486 @end{Reason}
2487
2488 When more than one @nt{condition} of an @nt{entry_barrier} of a protected
2489 object becomes True, and more than one of the respective queues is nonempty,
2490 the call with the highest priority is selected. If more than one such
2491 call has the same priority, the call that is queued on the entry whose
2492 declaration is first in textual order in the @nt{protected_definition} is
2493 selected. For members of the same entry family,
2494 the one with the lower family index is selected.
2495
2496 If the expiration time of two or more open
2497 @nt{delay_alternative}s is the same and no other
2498 @nt{accept_alternative}s are open, the
2499 @nt{sequence_of_statements} of the @nt{delay_alternative} that is
2500 first in textual order in the @nt{selective_accept} is executed.
2501
2502 When more than one alternative of a @nt{selective_accept} is
2503 open and has queued calls, an alternative whose queue has the highest-priority
2504 call at its head is selected.
2505 If two or more open alternatives have equal-priority queued calls,
2506 then a call on the entry in the @nt{accept_alternative} that is
2507 first in textual order in the @nt{selective_accept}
2508 is selected.
2509
2510 @end{itemize}
2511
2512 @end{RunTime}
2513
2514 @begin{ImplPerm}
2515 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]}
2516 Implementations are allowed to define other queuing policies, but
2517 need not support more than one @Chg{Version=[2],New=[queuing],Old=[such]}
2518 policy per partition.
2519 @begin{Discussion}
2520 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0116],ARef=[AI95-00069-01]}
2521 @ChgRef{Version=[2],Kind=[RevisedAdded],ARef=[AI95-00256-01]}
2522 @ChgAdded{Version=[1],Text=[This rule is really redundant, as
2523 @RefSecNum(Pragmas and Program Units) allows an implementation to limit the
2524 use of configuration pragmas to an empty environment. In that case, there
2525 would be no way to have multiple policies in a partition.@Chg{Version=[2],New=[],
2526 Old=[ In any case, the
2527 wording here really ought to be "...more than one queuing policy per
2528 partition.", since this part of the rule applies to all queuing policies, not
2529 just implementation-defined ones.]}]}
2530 @end{Discussion}
2531
2532 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00188-02]}
2533 @ChgAdded{Version=[2],Text=[Implementations are allowed to defer the reordering
2534 of entry queues following a change of base priority of a task blocked on the
2535 entry call if it is not practical to reorder the queue immediately.]}
2536 @begin{Reason}
2537 @ChgRef{Version=[2],Kind=[Added]}
2538 @ChgAdded{Version=[2],Text=[Priority change is immediate, but the effect of the
2539 change on entry queues can be deferred. That is necessary in order to implement
2540 priority changes on top of a non-Ada kernel.]}
2541 @end{Reason}
2542 @begin{Discussion}
2543 @ChgRef{Version=[2],Kind=[Added]}
2544 @ChgAdded{Version=[2],Text=[The reordering should occur as soon as the blocked
2545 task can itself perform the reinsertion into the entry queue.]}
2546 @end{Discussion}
2547 @end{ImplPerm}
2548
2549 @begin{ImplAdvice}
2550
2551 The implementation should use names that end with
2552 @lquotes@;_Queuing@rquotes@; for implementation-defined queuing policies.
2553
2554 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2555 Text=[Names that end with @lquotes@;_Queuing@rquotes@; should be used for
2556 implementation-defined queuing policies.]}]}
2557
2558 @end{ImplAdvice}
2559
2560 @begin{DiffWord95}
2561 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0074],ARef=[AI95-00068-01]}
2562 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the number of
2563 queuing policies defined.]}
2564
2565 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0075],ARef=[AI95-00205-01]}
2566 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected so that a call of
2567 Set_Priority in an abortable part does not change the priority of the
2568 triggering entry call.]}
2569
2570 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00188-02]}
2571 @ChgAdded{Version=[2],Text=[Added a permission to defer queue reordering
2572 when the base priority of a task is changed. This is a counterpart to
2573 stronger requirements on the implementation of priority change.]}
2574
2575 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]}
2576 @ChgAdded{Version=[2],Text=[Clarified that an implementation need support
2577 only one queuing policy (of any kind, language-defined or otherwise)
2578 per partition.]}
2579
2580 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
2581 @ChgAdded{Version=[2],Text=[Fixed wording to make clear that @nt{pragma}
2582 never appears inside of a unit; rather it @lquotes@;applies to@rquotes the
2583 unit.]}
2584 @end{DiffWord95}
2585
2586
2587 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
2588 @LabeledClause{Dynamic Priorities}
2589
2590
2591 @begin{Intro}
2592 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2593 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2594 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
2595 describes how the
2596 priority of an entity can be modified or queried at run time.]]}
2597 @end{Intro}
2598
2599 @begin{DiffWord95}
2600 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2601 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2602 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
2603 is turned into two subclauses. This @Chg{Version=[3],New=[subclause],Old=[clause]} introduction is new.]}
2604 @end{DiffWord95}
2605
2606
2607 @LabeledAddedSubClause{Version=[2],Name=[Dynamic Priorities for Tasks]}
2608
2609 @begin{Intro}
2610 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2611 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} describes
2612 how the base priority of a task can be modified or queried at run time.]
2613 @end{Intro}
2614
2615 @begin{StaticSem}
2616 @Leading@Keepnext@;The following language-defined library package exists:
2617 @begin{Example}
2618 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]}
2619 @key[with] System;
2620 @key[with] Ada.Task_Identification; @RI{-- See @RefSecNum[The Package Task_Identification]}
2621 @key[package] Ada.Dynamic_Priorities @key[is]@ChildUnit{Parent=[Ada],Child=[Dynamic_Priorities]}@Chg{Version=[2],New=[
2622 @key[pragma] Preelaborate(Dynamic_Priorities);],Old=[]}
2623
2624 @key[procedure] @AdaSubDefn{Set_Priority}(Priority : @key[in] System.Any_Priority;
2625 T : @key[in] Ada.Task_Identification.Task_Id :=
2626 Ada.Task_Identification.Current_Task);
2627
2628 @key[function] @AdaSubDefn{Get_Priority} (T : Ada.Task_Identification.Task_Id :=
2629 Ada.Task_Identification.Current_Task)
2630 @key[return] System.Any_Priority;
2631
2632 @key[end] Ada.Dynamic_Priorities;
2633 @end{example}
2634 @end{StaticSem}
2635
2636 @begin{RunTime}
2637 The procedure Set_Priority sets the base priority of the specified task
2638 to the specified Priority value.
2639 Set_Priority has no effect if the task is terminated.
2640
2641 The function Get_Priority returns T's current base priority.
2642 @Defn2{Term=[Tasking_Error],Sec=(raised by failure of run-time check)}
2643 Tasking_Error is raised if the task is terminated.
2644 @begin{Reason}
2645 There is no harm in setting the priority of a terminated task.
2646 A previous version of Ada 9X made this a run-time error.
2647 However, there is little difference between setting the priority of a
2648 terminated task, and setting the priority of a task that is about to
2649 terminate very soon;
2650 neither case should be an error.
2651 Furthermore, the run-time check is not necessarily feasible to implement
2652 on all systems, since priority changes might be deferred due to
2653 inter-processor communication overhead,
2654 so the error might not be detected until after Set_Priority has
2655 returned.
2656
2657 However, we wish to allow implementations to avoid storing @lquotes@;extra@rquotes@;
2658 information about terminated tasks.
2659 Therefore, we make Get_Priority of a terminated task raise an exception;
2660 the implementation need not continue to store the priority of a task
2661 that has terminated.
2662 @end{Reason}
2663
2664 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
2665 Program_Error is raised by Set_Priority and Get_Priority if T is equal
2666 to Null_Task_Id.
2667
2668 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00188-02]}
2669 @Chg{Version=[2],New=[On a system with a single processor, the setting of],
2670 Old=[Setting]} the @Chg{Version=[2],New=[],Old=[task's ]}base
2671 priority@Chg{Version=[2],New=[ of a task @i{T}],Old=[]}
2672 to the new value @Chg{Version=[2],
2673 New=[occurs immediately at the first point when @i{T} is
2674 outside the execution of],Old=[takes place as soon
2675 as is practical but not while the task is performing]} a
2676 protected action@Chg{Version=[2],New=[],Old=[.
2677 This setting occurs no later then the next abort completion point of
2678 the task T
2679 (see @RefSecNum{Abort of a Task - Abort of a Sequence of Statements})]}.
2680
2681 @begin{ImplNote}
2682 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00188-02]}
2683 @Chg{Version=[2],New=[The priority change is immediate if the target task
2684 is on a delay queue or a ready queue outside of a protected action.
2685 However, consider when],Old=[When]}
2686 Set_Priority is called by a task T1 to set the priority of T2,
2687 if T2 is blocked, waiting on an entry call queued on a protected object,
2688 the entry queue needs to be reordered.
2689 Since T1 might have a priority that is higher than the ceiling of the
2690 protected object, T1 cannot, in general, do the reordering.
2691 One way to implement this is to wake T2 up and have T2 do the work.
2692 This is similar to the disentangling of queues that needs to happen when
2693 a high-priority task aborts a lower-priority task,
2694 which might have a call queued on a protected object with a low
2695 ceiling.@Chg{Version=[2],New=[ We have an @ImplPermName in
2696 @RefSecNum{Entry Queuing Policies} to allow this implementation. We could
2697 have required an immediate priority change if on a ready queue during a
2698 protected action, but that would have required extra checks for ceiling
2699 violations to meet @BoundedName requirements of
2700 @RefSecNum{Priority Ceiling Locking} and potentially could cause a protected
2701 action to be abandoned in the middle (by raising Program_Error). That seems
2702 bad.],Old=[]}
2703 @end{ImplNote}
2704 @begin{Reason}
2705 @Leading@;A previous version of Ada 9X made it a run-time error
2706 for a high-priority task to set the priority of a lower-priority
2707 task that has a queued call on a protected object with a low ceiling.
2708 This was changed because:
2709 @begin{Itemize}
2710 The check was not feasible to implement on all systems,
2711 since priority changes might be deferred due to
2712 inter-processor communication overhead.
2713 The calling task would continue to execute without finding out whether
2714 the operation succeeded or not.
2715
2716 The run-time check would tend to cause intermittent system failures @em
2717 how is the caller supposed to know whether the other task happens to
2718 have a queued call at any given time? Consider for example an
2719 interrupt that needs to trigger a priority change in some task.
2720 The interrupt handler could not safely call Set_Priority without knowing
2721 exactly what the other task is doing,
2722 or without severely restricting the ceilings used in the system.
2723 If the interrupt handler wants to hand the job off to a third task whose
2724 job is to call Set_Priority, this won't help, because one would normally
2725 want the third task to have high priority.
2726 @end{Itemize}
2727 @end{Reason}
2728 @end{RunTime}
2729
2730 @begin{Bounded}
2731 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00327-01]}
2732 @ChgDeleted{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
2733 If a task is blocked on a protected entry call, and the call is queued,
2734 it is a bounded error to raise its base priority
2735 above the ceiling priority of the corresponding
2736 protected object.
2737 When an entry call is cancelled, it is a bounded error
2738 if the priority of the calling task is higher than
2739 the ceiling priority of the corresponding
2740 protected object.
2741 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
2742 In either of these cases,
2743 either Program_Error is raised in the task that called the entry,
2744 or its priority is temporarily lowered,
2745 or both, or neither.]}
2746 @begin{Ramification}
2747 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg]}
2748 @ChgDeleted{Version=[2],Text=[Note that the error is @lquotes@;blamed@rquotes@; on the task that did the entry call,
2749 not the task that called Set_Priority.
2750 This seems to make sense for the case of a task blocked on a call,
2751 since if the Set_Priority had happened a
2752 little bit sooner, before the task queued a call,
2753 the entry-calling task would get the error.
2754 In the other case, there is no reason not to raise the priority of a
2755 task that is executing in an @nt{abortable_part}, so long as its
2756 priority is lowered before it gets to the end and needs to cancel the
2757 call.
2758 The priority might need to be lowered to allow it to remove the call
2759 from the entry queue,
2760 in order to avoid violating the ceiling.
2761 This seems relatively harmless, since there is an error,
2762 and the task is about to start raising an exception anyway.]}
2763 @end{Ramification}
2764 @end{Bounded}
2765 @begin{NotIso}
2766 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraph 11 was
2767 deleted.>}]}@Comment{This message should be deleted if the paragraphs
2768 are ever renumbered.}
2769 @end{NotIso}
2770
2771 @begin{Erron}
2772 @PDefn2{Term=(erroneous execution),Sec=(cause)}
2773 If any subprogram in this package is called with a parameter T that
2774 specifies a task object that no longer exists, the execution of the
2775 program is erroneous.
2776 @begin{Ramification}
2777 Note that this rule overrides the above rule saying that
2778 Program_Error is raised on Get_Priority of a terminated task.
2779 If the task object still exists, and the task is terminated,
2780 Get_Priority raises Program_Error.
2781 However, if the task object no longer exists,
2782 calling Get_Priority causes erroneous execution.
2783 @end{Ramification}
2784 @end{Erron}
2785
2786 @begin{DocReq}
2787 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00188-02]}
2788 @ChgAdded{Version=[2],Text=[On a multiprocessor, the implementation shall
2789 document any conditions that cause the completion of the setting of the
2790 priority of a task to be delayed later than what is specified for a
2791 single processor.]}
2792 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
2793 Text=[Any conditions that cause the completion of the setting of the priority
2794 of a task to be delayed for a multiprocessor.]}]}
2795 @end{DocReq}
2796
2797 @begin{Metrics}
2798 @Leading@;The implementation shall document the following metric:
2799 @begin{Itemize}
2800 The execution time of a call to Set_Priority, for the nonpreempting case,
2801 in processor clock cycles. This is measured for a call that modifies the
2802 priority of a ready task that is not running (which
2803 cannot be the calling one), where the new
2804 base priority of the affected task is lower than the active priority of the
2805 calling task, and the affected task is not on any entry queue and is not
2806 executing a protected operation.
2807 @end{Itemize}
2808 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2809 Text=[The metrics for Set_Priority.]}]}
2810 @end{Metrics}
2811
2812 @begin{Notes}
2813
2814 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00321-01]}
2815 Setting a task's base priority affects task dispatching. First, it can
2816 change the task's active priority. Second, under the @Chg{Version=[2],
2817 New=[FIFO_Within_Priorities],Old=[standard
2818 task dispatching]} policy it always causes the task to move to
2819 the tail of the ready queue corresponding to its active priority,
2820 even if the new base priority is unchanged.
2821
2822 Under the priority queuing policy, setting a task's base
2823 priority has an effect on a queued entry call
2824 if the task is blocked waiting for the call. That is, setting the
2825 base priority of a task causes the priority of a queued entry
2826 call from that task to be updated and the call to be removed and
2827 then reinserted in the entry queue at the new priority
2828 (see @RefSecNum{Entry Queuing Policies}),
2829 unless the call originated from the @nt{triggering_statement} of an
2830 @nt{asynchronous_select}.
2831
2832 The effect of two or more Set_Priority calls executed in parallel on
2833 the same task is defined as executing these calls in some serial order.
2834
2835 @begin{TheProof}
2836 This follows from the general reentrancy requirements stated near the
2837 beginning of @RefSec{Predefined Language Environment}.
2838 @end{TheProof}
2839
2840 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0092-1]}
2841 The rule for when Tasking_Error is raised for Set_Priority or Get_Priority is
2842 different from the rule for when Tasking_Error is raised on an
2843 entry call (see @RefSecNum{Entry Calls}). In particular,
2844 @Chg{Version=[3],New=[],Old=[setting or ]}querying the priority of
2845 a completed or an abnormal
2846 task is allowed, so long as the task is not yet
2847 terminated@Chg{Version=[3],New=[, and setting the priority of a task
2848 is allowed for any task state (including for terminated tasks)],Old=[]}.
2849
2850 Changing the priorities of a set of tasks can be performed by a
2851 series of calls to Set_Priority for each task separately. For
2852 this to work reliably, it should be done within a protected
2853 operation that has high enough ceiling priority to guarantee that
2854 the operation completes without being preempted by any of the
2855 affected tasks.
2856
2857 @end{Notes}
2858
2859 @begin{Extend95}
2860 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00188-02]}
2861 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
2862 @b[Amendment Correction:] Priority changes are
2863 now required to be done immediately so long as the target task is not on an
2864 entry queue.]}
2865
2866 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
2867 @ChgAdded{Version=[2],Text=[Dynamic_Priorities is now Preelaborated,
2868 so it can be used in preelaborated units.]}
2869 @end{Extend95}
2870
2871 @begin{DiffWord95}
2872 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2873 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2874 @ChgAdded{Version=[2],Text=[This Ada 95 @Chg{Version=[3],New=[subclause],
2875 Old=[clause]} was @Chg{Version=[3],New=[moved down a level],Old=[turned
2876 into a subclause]}. The paragraph numbers are the same as those for
2877 @RefSecNum{Dynamic Priorities} in Ada 95.]}
2878
2879 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00321-01]}
2880 @ChgAdded{Version=[2],Text=[There is no @lquotes@;standard@rquotes policy
2881 anymore, so that phrase was replaced by the name of a specific policy in
2882 the notes.]}
2883
2884 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2885 @ChgAdded{Version=[2],Text=[The bounded error for the priority of a task
2886 being higher than the ceiling of an object it is currently in was moved
2887 to @RefSecNum{Priority Ceiling Locking}, so that it applies no matter how
2888 the situation arises.]}
2889 @end{DiffWord95}
2890
2891
2892 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
2893 @LabeledAddedSubClause{Version=[2],Name=[Dynamic Priorities for Protected Objects]}
2894
2895 @begin{Intro}
2896 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2897 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2898 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
2899 specifies how the priority of a protected object can be modified or
2900 queried at run time.]}
2901 @end{Intro}
2902
2903 @begin{StaticSem}
2904
2905 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2906 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The following attribute
2907 is defined for @PrefixType{a @nt{prefix} P that denotes a protected object}:]}
2908
2909 @begin(Description)
2910 @ChgAttribute{Version=[2],Kind=[AddedNormal],ChginAnnex=[T],
2911 Leading=<F>, Prefix=<P>, AttrName=<Priority>, ARef=[AI95-00327-01],
2912 Text=[@Chg{Version=[2],New=[Denotes a non-aliased component of the
2913 protected object P. This component is of type System.Any_Priority and its
2914 value is the priority of P. P'Priority denotes a variable if and only if P
2915 denotes a variable. A reference to this attribute shall appear only
2916 within the body of P.],Old=[]}]}
2917 @EndPrefixType{}
2918 @end{Description}
2919
2920 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2921 @ChgAdded{Version=[2],Text=[The initial value of this attribute is
2922 the initial value of the priority of the protected object@Redundant[, and can
2923 be changed by an assignment].]}
2924 @end{StaticSem}
2925
2926 @begin{Runtime}
2927 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2928 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2929 @ChgAdded{Version=[2],Text=[If the locking policy Ceiling_Locking (see
2930 @RefSecNum{Priority Ceiling Locking}) is in effect@Chg{Version=[3],New=[,],Old=[]}
2931 then the ceiling priority of a protected object @i<P> is set to the value of
2932 @i<P>'Priority at the end of each protected action of @i<P>.]}
2933
2934 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00445-01]}
2935 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
2936 @ChgAdded{Version=[2],Text=[If the locking policy Ceiling_Locking is in effect,
2937 then for a protected object @i<P> with either an Attach_Handler or
2938 Interrupt_Handler @Chg{Version=[3],New=[aspect specified
2939 for],Old=[pragma applying to]} one of its procedures, a check is made
2940 that the value to be assigned to @i<P>'Priority is in the range
2941 System.Interrupt_Priority. If the check fails, Program_Error is
2942 raised.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
2943 @end{Runtime}
2944
2945 @begin{Metrics}
2946
2947 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2948 @ChgAdded{Version=[2],Type=[Leading],Text=[The implementation shall document
2949 the following metric:]}
2950
2951 @begin{Itemize}
2952 @ChgRef{Version=[2],Kind=[AddedNormal]}
2953 @ChgAdded{Version=[2],Type=[Leading],Text=[The difference in execution time of
2954 calls to the following procedures in protected object P:]}
2955
2956 @begin{Example}
2957 @ChgRef{Version=[2],Kind=[AddedNormal]}
2958 @ChgAdded{Version=[2],Text=[@key<protected> P @key<is>
2959 @key<procedure> Do_Not_Set_Ceiling (Pr : System.Any_Priority);
2960 @key<procedure> Set_Ceiling (Pr : System.Any_Priority);
2961 @key<end> P;]}
2962
2963 @ChgRef{Version=[2],Kind=[AddedNormal]}
2964 @ChgAdded{Version=[2],Text=[@key<protected body> P @key<is>
2965 @key<procedure> Do_Not_Set_Ceiling (Pr : System.Any_Priority) @key<is>
2966 @key<begin>
2967 @key<null>;
2968 @key<end>;
2969 @key<procedure> Set_Ceiling (Pr : System.Any_Priority) @key<is>
2970 @key<begin>
2971 P'Priority := Pr;
2972 @key<end>;
2973 @key<end> P;]}
2974 @end{Example}
2975 @end{Itemize}
2976 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2977 Text=[The metrics for setting the priority of a protected object.]}]}
2978 @end{Metrics}
2979
2980 @begin{Notes}
2981 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
2982 @ChgAdded{Version=[2],Text=[Since P'Priority is a normal variable, the value
2983 following an assignment to the attribute immediately reflects the new value
2984 even though its impact on the ceiling priority of P is postponed until
2985 completion of the protected action in which it is executed.]}
2986 @end{Notes}
2987
2988 @begin{Extend95}
2989 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01],ARef=[AI95-00445-01]}
2990 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
2991 The ability to dynamically change and query the priority of a protected
2992 object is new.]}
2993 @end{Extend95}
2994
2995
2996 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
2997 @LabeledClause{Preemptive Abort}
2998
2999 @begin{Intro}
3000 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3001 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
3002 requirements on the immediacy with which an aborted construct is completed.]
3003 @end{Intro}
3004
3005 @begin{RunTime}
3006
3007 On a system with a single processor, an aborted construct is completed
3008 immediately at the first point that is outside the execution of an
3009 abort-deferred operation.
3010
3011 @end{RunTime}
3012
3013 @begin{DocReq}
3014 On a multiprocessor, the implementation shall document any conditions that
3015 cause the completion of an aborted construct to be delayed later than
3016 what is specified for a single processor.
3017 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
3018 Text=[@ChgDeleted{Version=[2],
3019 Text=[On a multiprocessor, any conditions that
3020 cause the completion of an aborted construct to be delayed later than
3021 what is specified for a single processor.]}]}
3022 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3023 Text=[On a multiprocessor, any conditions that
3024 cause the completion of an aborted construct to be delayed later than
3025 what is specified for a single processor.]}]}
3026 @end{DocReq}
3027
3028 @begin{Metrics}
3029 @Leading@;The implementation shall document the following metrics:
3030 @begin{Itemize}
3031 The execution time, in processor clock cycles, that it takes for an
3032 @nt{abort_statement} to cause the completion of the aborted task.
3033 This is measured in a situation where a task T2 preempts task T1
3034 and aborts T1. T1 does not have any finalization code. T2 shall
3035 verify that T1 has terminated, by means of the Terminated attribute.
3036
3037 On a multiprocessor, an upper bound in seconds,
3038 on the time that the completion of an aborted task can be delayed beyond
3039 the point that it is required for a single processor.
3040
3041 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
3042 An upper bound on the execution time of an
3043 @nt{asynchronous_select}, in processor clock cycles. This is measured
3044 between a point immediately before a task
3045 T1 executes a protected operation Pr.Set that makes the @nt{condition}
3046 of an @nt{entry_barrier} Pr.Wait @Chg{Version=[2],
3047 New=[True],Old=[true]}, and the point where task T2 resumes
3048 execution immediately after an entry call to Pr.Wait in an
3049 @nt{asynchronous_select}. T1 preempts T2 while
3050 T2 is executing the abortable part, and then blocks itself so that
3051 T2 can execute. The execution time of T1 is measured separately,
3052 and subtracted.
3053
3054 An upper bound on the execution time of an
3055 @nt{asynchronous_select},
3056 in the case that no asynchronous transfer of control takes
3057 place. This is measured between a point immediately before a task
3058 executes the @nt{asynchronous_select} with a nonnull abortable
3059 part, and the point where the task continues execution immediately after
3060 it. The execution time of the abortable part is subtracted.
3061 @end{Itemize}
3062 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3063 Text=[The metrics for aborts.]}]}
3064 @end{Metrics}
3065
3066 @begin{ImplAdvice}
3067
3068 Even though the @nt{abort_statement} is included in the list of
3069 potentially blocking operations
3070 (see @RefSecNum{Protected Subprograms and Protected Actions}),
3071 it is recommended that this statement be implemented in a way that
3072 never requires the task executing the @nt{abort_statement} to
3073 block.
3074
3075 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3076 Text=[The @nt{abort_statement} should not require the task executing the
3077 statement to block.]}]}
3078
3079 On a multi-processor,
3080 the delay associated with aborting a task on another processor
3081 should be bounded;
3082 the implementation should use periodic polling,
3083 if necessary, to achieve this.
3084
3085 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3086 Text=[On a multi-processor,
3087 the delay associated with aborting a task on another processor
3088 should be bounded.]}]}
3089
3090 @end{ImplAdvice}
3091
3092 @begin{Notes}
3093
3094 Abortion does not change the active or base priority of the aborted task.
3095
3096 Abortion cannot be more immediate than is allowed by the rules for
3097 deferral of abortion during finalization and in protected actions.
3098
3099 @end{Notes}
3100
3101
3102 @LabeledClause{Tasking Restrictions}
3103
3104 @begin{Intro}
3105 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3106 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} defines
3107 restrictions that can be used with a
3108 pragma Restrictions (see @RefSecNum{Pragma Restrictions and Pragma Profile}) to facilitate the
3109 construction of highly efficient tasking run-time systems.]
3110 @end{Intro}
3111
3112 @begin{StaticSem}
3113 @Leading@;The following @SynI{restriction_}@nt{identifier}s are language defined:
3114 @begin{Description}
3115 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0013-1],ARef=[AI05-0216-1]}
3116 @Defn2{Term=[restrictions],Sec=(No_Task_Hierarchy)}@Chg{Version=[3],New=[@Defn{No_Task_Hierarchy restriction}],
3117 Old=[]}No_Task_Hierarchy @\@Chg{Version=[3],
3118 New=[No task depends on a master other than the library-level master],Old=[All
3119 (nonenvironment) tasks depend directly on
3120 the environment task of the partition]}.
3121
3122 @begin{Ramification}
3123 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0216-1]}
3124 @ChgAdded{Version=[3],Text=[This is equivalent to saying @ldquote@;no task
3125 depends on a master other than the
3126 master that is the execution of the body of the environment task of the
3127 partition@rdquote, but it is much easier to understand. This is a
3128 post-compilation check, which can be checked at compile-time.]}
3129
3130 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0013-1]}
3131 @ChgAdded{Version=[3],Text=[This disallows any function returning an
3132 object with a task part or coextension, even if called at the library level,
3133 as such a task would temporarily depend on a nested master (the master
3134 of the return statement), which is disallowed by this restriction.]}
3135 @end{Ramification}
3136
3137 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0042],ARef=[AI95-00130-01]}
3138 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00360-01]}
3139 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0013-1]}
3140 @Defn2{Term=[restrictions],Sec=(No_Nested_Finalization)}@Chg{Version=[3],New=[@Defn{No_Nested_Finalization restriction}],
3141 Old=[]}No_Nested_Finalization @\Objects
3142 @Chg{Version=[2],New=[of a type that needs finalization (see
3143 @RefSecNum{Assignment and Finalization})],Old=[with
3144 controlled@Chg{New=[, protected, or task],Old=[]} parts]}
3145 @Chg{Version=[3],New=[are],Old=[and
3146 access types that designate @Chg{Version=[2],New=[a type that needs
3147 finalization],Old=[such objects@Chg{New=[,],Old=[]}]} shall be]}
3148 declared only at library level.@Chg{Version=[3],New=[ If an access type
3149 does not have library-level accessibility, then there are
3150 no @nt{allocator}s of the type where the type determined by the
3151 @nt{subtype_mark} of the @nt{subtype_indication} or
3152 @nt{qualified_expression} needs finalization.],Old=[]}
3153 @begin{Ramification}
3154 @ChgRef{Version=[1],Kind=[Deleted],Ref=[8652/0042],ARef=[AI95-00130-01]}
3155 @ChgNote{This is no longer true.}
3156 @ChgDeleted{Version=[1],Text=[Note that protected types with entries and
3157 interrupt-handling protected types have nontrivial finalization actions.
3158 However, this restriction does not restrict those things.]}
3159
3160 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0013-1]}
3161 @ChgAdded{Version=[3],Text=[The second sentence prevents the declaration
3162 of objects of access types which would require nested finalization. It
3163 also prevents the declarations of coextensions that need
3164 finalization in a nested scope. The latter cannot be done by preventing
3165 the declaration of the objects, as it is not necessarily known if the
3166 coextension type needs finalization (it could be a limited view).]}
3167 @end{Ramification}
3168
3169 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0211-1]}
3170 @Defn2{Term=[restrictions],Sec=(No_Abort_Statements)}@Chg{Version=[3],New=[@Defn{No_Abort_Statements restriction}],
3171 Old=[]}No_Abort_Statements @\There are no @nt{abort_statement}s, and there
3172 @Chg{Version=[3],New=[is no use of a @nt{name} denoting],Old=[are no calls on]}
3173 Task_Identification.Abort_Task.
3174
3175 @Defn2{Term=[restrictions],Sec=(No_Terminate_Alternatives)}@Chg{Version=[3],New=[@Defn{No_Terminate_Alternatives restriction}],
3176 Old=[]}No_Terminate_Alternatives @\There are no @nt{selective_accept}s with
3177 @nt{terminate_alternative}s.
3178
3179 @Defn2{Term=[restrictions],Sec=(No_Task_Allocators)}@Chg{Version=[3],New=[@Defn{No_Task_Allocators restriction}],
3180 Old=[]}No_Task_Allocators @\There are no @nt{allocator}s for task types or types
3181 containing task subcomponents.
3182
3183 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0224-1]}
3184 @ChgAdded{Version=[3],NoPrefix=[T],Text=[In the case of an initialized
3185 @nt{allocator} of an access type whose designated type is class-wide and
3186 limited, a check is made that the specific type of the allocated object has
3187 no task subcomponents. Program_Error is raised if this check
3188 fails.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
3189 @Comment{We don't index this "check" as it doesn't have a name.}
3190
3191 @Defn2{Term=[restrictions],Sec=(No_Implicit_Heap_Allocations)}@Chg{Version=[3],New=[@Defn{No_Implicit_Heap_Allocations restriction}],
3192 Old=[]}No_Implicit_Heap_Allocations @\There are no operations that implicitly require
3193 heap storage allocation to be performed by the
3194 implementation. The operations that implicitly
3195 require heap storage allocation are
3196 implementation defined.
3197 @ImplDef{Any operations that implicitly
3198 require heap storage allocation.}
3199
3200 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00327-01]}
3201 No_Dynamic_Priorities @\There are no semantic dependences on the package
3202 Dynamic_Priorities@Chg{Version=[2],New=[, and no occurrences
3203 of the attribute Priority],Old=[]}.
3204 @Defn2{Term=[restrictions],Sec=(No_Dynamic_Priorities)}@Chg{Version=[3],New=[@Defn{No_Dynamic_Priorities restriction}],
3205 Old=[]}
3206
3207 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00305-01],ARef=[AI95-00394-01]}
3208 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0013-1],ARef=[AI05-0211-1]}
3209 @Chg{Version=[2],New=[@Defn2{Term=[restrictions],
3210 Sec=(No_Dynamic_Attachment)}@Chg{Version=[3],New=[@Defn{No_Dynamic_Attachment restriction}],
3211 Old=[]}No_Dynamic_Attachment],
3212 Old=[@Defn2{Term=[restrictions],Sec=(No_Asynchronous_Control)}No_Asynchronous_Control]}
3213 @\There
3214 @Chg{Version=[2],New=[is no @Chg{Version=[3],New=[use of a @nt{name}
3215 denoting],Old=[call to]} any of the operations defined
3216 in package Interrupts (Is_Reserved, Is_Attached, Current_Handler,
3217 Attach_Handler, Exchange_Handler, Detach_Handler, and Reference).],
3218 Old=[are no semantic dependences on the package Asynchronous_Task_Control.]}
3219 @begin{Ramification}
3220 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0013-1]}
3221 @ChgAdded{Version=[3],Text=[This includes 'Access and 'Address of any
3222 of these operations, as well as inherited versions of these operations.]}
3223 @end{Ramification}
3224
3225
3226 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0055-1]}
3227 @ChgAdded{Version=[4],Text=[@Defn2{Term=[restrictions],Sec=(No_Dynamic_CPU_Assignment)}@Defn{No_Dynamic_CPU_Assigmment restriction}
3228 No_Dynamic_CPU_Assignment @\No task has the CPU aspect specified to be
3229 a non-static expression.
3230 Each task (including the environment task) that has the CPU aspect
3231 specified as Not_A_Specific_CPU will be assigned to a particular
3232 implementation-defined CPU. The same is true for the environment task
3233 when the CPU aspect is not specified. @Redundant[Any other task without
3234 a CPU aspect will activate and execute on the same processor as its
3235 activating task.]]}
3236 @begin{TheProof}
3237 @ChgRef{Version=[4],Kind=[AddedNormal]}
3238 @ChgAdded{Version=[4],Text=[The processor of a task without a CPU aspect is
3239 defined in @RefSecNum{Multiprocessor Implementation}, and this restriction
3240 guarantees that the activator always has a CPU assigned.]}
3241 @end{TheProof}
3242 @begin{Reason}
3243 @ChgRef{Version=[4],Kind=[AddedNormal]}
3244 @ChgAdded{Version=[4],Text=[This restriction prevents any migration of tasks.]}
3245 @end{Reason}
3246 @begin{Ramification}
3247 @ChgRef{Version=[4],Kind=[AddedNormal]}
3248 @ChgAdded{Version=[4],Text=[If no CPU aspects are specified, then the program
3249 will run on a single CPU, as all of the tasks will be activated directly or
3250 indirectly by the environment task, and the rules require the same CPU to be
3251 used as the activating task. ]}
3252 @end{Ramification}
3253 @ChgImplDef{Version=[4],Kind=[Added],Text=[@ChgAdded{Version=[4],
3254 Text=[When restriction No_Dynamic_CPU_Assignment applies to a partition,
3255 the processor on which a task with a CPU value of a Not_A_Specific_CPU
3256 will execute.]}]}
3257
3258 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3259 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0013-1]}
3260 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Local_Protected_Objects)}@Chg{Version=[3],New=[@Defn{No_Local_Protected_Objects restriction}],
3261 Old=[]}No_Local_Protected_Objects @\Protected
3262 objects @Chg{Version=[3],New=[are],Old=[shall be]} declared only at
3263 library level.]}
3264
3265 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00297-01]}
3266 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0013-1]}
3267 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Local_Timing_Events)}@Chg{Version=[3],New=[@Defn{No_Local_Timing_Events restriction}],
3268 Old=[]}No_Local_Timing_Events @\Timing_Events
3269 @Chg{Version=[3],New=[are],Old=[shall be]} declared only at library level.]}
3270
3271 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3272 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Protected_Type_Allocators)}@Chg{Version=[3],New=[@Defn{No_Protected_Type_Allocators restriction}],
3273 Old=[]}No_Protected_Type_Allocators @\There
3274 are no @nt{allocator}s for protected types or types
3275 containing protected type subcomponents.]}
3276
3277 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0224-1]}
3278 @ChgAdded{Version=[3],NoPrefix=[T],Text=[In the case of an initialized
3279 @nt{allocator} of an access type whose designated type is class-wide and
3280 limited, a check is made that the specific type of the allocated object has
3281 no protected subcomponents. Program_Error is raised if this check
3282 fails.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
3283 @Comment{We don't index this "check" as it doesn't have a name.}
3284
3285 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3286 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0211-1]}
3287 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Relative_Delay)}@Chg{Version=[3],New=[@Defn{No_Relative_Delay restriction}],
3288 Old=[]}No_Relative_Delay @\There
3289 are no @nt{delay_relative_statement}s@Chg{Version=[3],New=[, and there is no
3290 use of a @nt{name} that denotes the Timing_Events.Set_Handler
3291 subprogram that has a Time_Span parameter],Old=[]}.]}
3292
3293 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3294 @ChgRef{Version=[3],Kind=[RevisedAdded]}@Comment{Number changed due to insertion above}
3295 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Requeue_Statements)}@Chg{Version=[3],New=[@Defn{No_Requeue_Statements restriction}],
3296 Old=[]}No_Requeue_Statements @\There
3297 are no @nt{requeue_statement}s.]}
3298
3299 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3300 @ChgRef{Version=[3],Kind=[RevisedAdded]}@Comment{Number changed due to insertion above}
3301 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Select_Statements)}@Chg{Version=[3],New=[@Defn{No_Select_Statements restriction}],
3302 Old=[]}No_Select_Statements @\There
3303 are no @nt{select_statement}s.]}
3304
3305 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00394-01]}
3306 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0211-1]}
3307 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Specific_Termination_Handlers)}@Chg{Version=[3],New=[@Defn{No_Specific_Termination_Handlers restriction}],
3308 Old=[]}No_Specific_Termination_Handlers @\There
3309 @Chg{Version=[3],New=[is no use of a @nt{name} denoting],Old=[are no calls to]}
3310 the Set_Specific_Handler and Specific_Handler subprograms
3311 in Task_Termination.]}
3312
3313 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0117-1]}
3314 @ChgAdded{Version=[4],Text=[@Defn2{Term=[restrictions],Sec=(No_Tasks_Unassigned_To_CPU)}@Defn{No_Tasks_Unassigned_To_CPU restriction}
3315 No_Tasks_Unassigned_To_CPU @\The CPU aspect is specified for the environment
3316 task. No CPU aspect is specified to be statically equal to
3317 Not_A_Specific_CPU. If aspect CPU is specified (dynamically) to the value
3318 Not_A_Specific_CPU, then Program_Error is raised. If Set_CPU or
3319 Delay_Until_And_Set_CPU are called with the CPU parameter equal to
3320 Not_A_Specific_CPU, then Program_Error is raised.]}
3321 @begin{Ramification}
3322 @ChgRef{Version=[4],Kind=[AddedNormal]}
3323 @ChgAdded{Version=[4],Text=[If this restriction is used in a context for which
3324 restriction No_Dynamic_CPU_Assignment is in effect, then no runtime check
3325 is needed when specifying the CPU aspect. If the restriction is used with
3326 the Ravenscar profile, no runtime checks are needed.]}
3327 @end{Ramification}
3328 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3329 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0013-1]}
3330 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(Simple_Barriers)}@Chg{Version=[3],New=[@Defn{Simple_Barriers restriction}],
3331 Old=[]}Simple_Barriers @\The
3332 Boolean expression in @Chg{Version=[3],New=[each],Old=[an]} entry barrier
3333 @Chg{Version=[3],New=[is],Old=[shall be]} either a static
3334 @Chg{Version=[3],New=[],Old=[Boolean ]}expression or a
3335 @Chg{Version=[3],New=[name that statically denotes a],Old=[Boolean]}
3336 component of the enclosing protected object.]}
3337
3338 @end{Description}
3339
3340 @Leading@;The following @SynI{restriction_parameter_}@nt{identifier}s are
3341 language defined:
3342 @begin{Description}
3343 @Defn2{Term=[restrictions],Sec=(Max_Select_Alternatives)}@Chg{Version=[3],New=[@Defn{Max_Select_Alternatives restriction}],
3344 Old=[]}Max_Select_Alternatives @\Specifies the maximum number of alternatives
3345 in a @nt{selective_accept}.
3346
3347 @Defn2{Term=[restrictions],Sec=(Max_Task_Entries)}@Chg{Version=[3],New=[@Defn{Max_Task_Entries restriction}],
3348 Old=[]}Max_Task_Entries @\Specifies the maximum number of entries per task.
3349 The bounds of every entry family
3350 of a task unit shall be static,
3351 or shall be defined by a discriminant of a subtype whose
3352 corresponding bound is static.
3353 @Redundant[A value of zero indicates that no rendezvous
3354 are possible.]
3355
3356 Max_Protected_Entries @\Specifies the maximum number of entries per
3357 protected type.
3358 The bounds of every entry family
3359 of a protected unit shall be static,
3360 or shall be defined by a discriminant of a subtype whose
3361 corresponding bound is static.
3362 @Defn2{Term=[restrictions],Sec=(Max_Protected_Entries)}@Chg{Version=[3],New=[@Defn{Max_Protected_Entries restriction}],
3363 Old=[]}
3364 @end{Description}
3365 @end{StaticSem}
3366
3367 @begin{RunTime}
3368
3369 @ChgRef{Version=[1],Kind=[Deleted],Ref=[8652/0076],ARef=[AI95-00067-01]}
3370 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00305-01]}
3371 @ChgAdded{Version=[2],Type=[Leading],Text=[The following
3372 @SynI{restriction_}@nt{identifier} is language defined:]}@Comment{Use ChgAdded so
3373 we get conditional Leading.}@Chg{Version=[1],New=[],Old=[If the following restrictions
3374 are violated, the behavior is implementation defined.
3375 @IndexCheck{Storage_Check}
3376 @Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)}
3377 If an implementation chooses to detect such a violation,
3378 Storage_Error should be raised.]}
3379
3380 @begin{Description}
3381 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01],ARef=[AI95-00394-01]}
3382 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],Sec=(No_Task_Termination)}@Chg{Version=[3],New=[@Defn{No_Task_Termination restriction}],
3383 Old=[]}No_Task_Termination @\All
3384 tasks are nonterminating. It is implementation-defined what happens if
3385 a task attempts to terminate. If there is a fall-back handler (see C.7.3)
3386 set for the partition it should be called when the first task attempts to
3387 terminate.]}
3388 @ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3389 Text=[When restriction No_Task_Termination applies to a partition, what
3390 happens when a task terminates.]}]}
3391 @end{Description}
3392
3393 @Leading@;The following @SynI{restriction_parameter_}@nt{identifier}s are
3394 language defined:
3395 @begin{Description}
3396 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]}
3397 @Defn2{Term=[restrictions],Sec=(Max_Storage_At_Blocking)}@Chg{Version=[3],New=[@Defn{Max_Storage_At_Blocking restriction}],
3398 Old=[]}Max_Storage_At_Blocking @\Specifies
3399 the maximum portion @redundant[(in storage elements)]
3400 of a task's Storage_Size that can be retained by a blocked task@Chg{New=[.
3401 If an implementation chooses to detect a violation of this
3402 restriction, Storage_Error should be raised;
3403 @IndexCheck{Storage_Check}
3404 @Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)}
3405 otherwise, the behavior is implementation defined],Old=[]}.
3406 @ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3407 Text=[The behavior when restriction Max_Storage_At_Blocking is violated.]}]}
3408
3409 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]}
3410 @Defn2{Term=[restrictions],Sec=(Max_Asynchronous_Select_Nesting)}@Chg{Version=[3],New=[@Defn{Max_Asynchronous_Select_Nesting restriction}],
3411 Old=[]}Max_Asynchronous_Select_Nesting @\Specifies
3412 the maximum dynamic nesting level of @nt{asynchronous_select}s.
3413 A value of zero prevents the use of any @nt{asynchronous_@!select}@Chg{New=[ and,
3414 if a program contains an @nt{asynchronous_@!select}, it is illegal.
3415 @ChgNote{Part of the previous rule is redundant, but it is a different part
3416 [all of it for Old; from "prevents" to "and," for New] for each. So we omit it.}
3417 If an implementation chooses to detect a violation of this
3418 restriction for values other than zero, Storage_Error should be raised;
3419 @IndexCheck{Storage_Check}
3420 @Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)}
3421 otherwise, the behavior is implementation defined],Old=[]}.
3422 @ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3423 Text=[The behavior when restriction Max_Asynchronous_Select_Nesting is violated.]}]}
3424
3425 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0076],ARef=[AI95-00067-01]}
3426 @Defn2{Term=[restrictions],Sec=(Max_Tasks)}@Chg{Version=[3],New=[@Defn{Max_Tasks restriction}],
3427 Old=[]}Max_Tasks @\Specifies the maximum
3428 number of task creations that may be executed over the lifetime of a
3429 partition, not counting the creation of the environment task@Chg{New=[.
3430 A value of zero prevents any task creation and, if a program contains a
3431 task creation, it is illegal. If an implementation chooses to detect a
3432 violation of this restriction, Storage_Error should be raised;
3433 @IndexCheck{Storage_Check}
3434 @Defn2{Term=[Storage_Error],Sec=(raised by failure of run-time check)}
3435 otherwise, the behavior is implementation defined],Old=[]}.
3436 @begin{Ramification}
3437 Note that this is not a limit on the
3438 number of tasks active at a given time;
3439 it is a limit on the total number of task creations that occur.
3440 @end{Ramification}
3441 @begin{ImplNote}
3442 We envision an implementation approach that places TCBs or pointers
3443 to them in a fixed-size table, and never reuses table elements.
3444 @end{ImplNote}
3445 @ChgImplDef{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3446 Text=[The behavior when restriction Max_Tasks is violated.]}]}
3447
3448 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00305-01]}
3449 @ChgAdded{Version=[2],Text=[@Defn2{Term=[restrictions],
3450 Sec=(Max_Entry_Queue_Length)}@Chg{Version=[3],New=[@Defn{Max_Entry_Queue_Length restriction}],
3451 Old=[]}Max_Entry_Queue_Length @\Max_Entry_Queue_Length
3452 defines the maximum number of calls
3453 that are queued on an entry. Violation of this restriction
3454 results in the raising of Program_Error at the point of the call or
3455 requeue.@Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}]}
3456
3457 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0189-1]}
3458 @ChgAdded{Version=[3],Text=[@Defn2{Term=[restrictions],
3459 Sec=(No_Standard_Allocators_After_Elaboration)}@Defn{No_Standard_Allocators_After_Elaboration restriction}
3460 No_Standard_Allocators_After_Elaboration @\Specifies that an @nt{allocator} using
3461 a standard storage pool (see @RefSecNum{Storage Management}) shall not occur
3462 within a parameterless library subprogram, nor within the
3463 @nt{handled_sequence_of_statements} of a task body. For the purposes of this rule, an
3464 @nt{allocator} of a type derived from a formal access type does not use a standard
3465 storage pool.]}
3466
3467 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0189-1],ARef=[AI05-0262-1]}
3468 @ChgAdded{Version=[3],NoPrefix=[T],Text=[At run time, Storage_Error is raised if
3469 an @nt{allocator} using a standard storage pool is evaluated after the elaboration of
3470 the @nt{library_item}s of the partition has completed.@Defn2{Term=[Storage_Error],
3471 Sec=(raised by failure of run-time check)}]}
3472 @end{Description}
3473
3474 It is implementation defined whether the use of pragma Restrictions
3475 results in a reduction in executable program size, storage requirements,
3476 or execution time. If possible, the implementation should provide
3477 quantitative descriptions of such effects for each restriction.
3478 @ChgImplDef{Version=[2],Kind=[Revised],InitialVersion=[0],
3479 Text=[@Chg{Version=[2],
3480 New=[Whether the use of],Old=[Implementation-defined aspects of]}
3481 pragma Restrictions@Chg{Version=[2],New=[ results in a reduction in
3482 program code or data size or execution time],Old=[]}.]}
3483 @end{RunTime}
3484
3485 @begin{ImplAdvice}
3486 When feasible, the implementation should take advantage of the specified
3487 restrictions to produce a more efficient implementation.
3488
3489 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3490 Text=[When feasible, specified restrictions should be used to produce a more
3491 efficient implementation.]}]}
3492 @end{ImplAdvice}
3493
3494 @begin{Notes}
3495 The above Storage_Checks can be suppressed with pragma Suppress.
3496 @end{Notes}
3497
3498 @begin{Incompatible95}
3499 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00360-01]}
3500 @ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
3501 @b[Amendment Correction:] The No_Nested_Finalization is now defined in terms
3502 of types that need finalization. These types include a variety of
3503 language-defined types that @i<might> be implemented with a controlled type.
3504 If the restriction No_Nested_Finalization (see
3505 @RefSecNum{Tasking Restrictions}) applies to the partition, and one of these
3506 language-defined types does not have a controlled part, it will not be
3507 allowed in local objects in Ada 2005 whereas it would be allowed in original
3508 Ada 95. Such code is not portable, as other Ada compilers may have had a
3509 controlled part, and thus would be illegal under the restriction.]}
3510 @end{Incompatible95}
3511
3512 @begin{Extend95}
3513 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01],ARef=[AI95-00305-01],ARef=[AI95-00394-01]}
3514 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
3515 Restrictions No_Dynamic_Attachment, No_Local_Protected_Objects,
3516 No_Protected_Type_Allocators, No_Local_Timing_Events, No_Relative_Delay,
3517 No_Requeue_Statement, No_Select_Statements, No_Specific_Termination_Handlers,
3518 No_Task_Termination, Max_Entry_Queue_Length, and Simple_Barriers are newly
3519 added to Ada.]}
3520 @end{Extend95}
3521
3522 @begin{DiffWord95}
3523 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0042],ARef=[AI95-00130-01]}
3524 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that
3525 No_Nested_Finalization covered task and protected parts as well.]}
3526
3527 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0076],ARef=[AI95-00067-01]}
3528 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Changed the description of
3529 Max_Tasks and Max_Asynchronous_Select_Nested to eliminate conflicts with the
3530 High Integrity Annex (see @RefSecNum{High Integrity Restrictions}).]}
3531
3532 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00327-01]}
3533 @ChgAdded{Version=[2],Text=[Added using of the new Priority attribute to
3534 the restriction No_Dynamic_Priorities.]}
3535
3536 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00394-01]}
3537 @ChgAdded{Version=[2],Text=[Restriction No_Asynchronous_Control is now
3538 obsolescent.]}
3539 @end{DiffWord95}
3540
3541 @begin{Incompatible2005}
3542 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0013-1]}
3543 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}@b<Correction:>
3544 Changed so that coextensions of types that require nested finalization are
3545 also prohibited; this is done by prohibiting @nt{allocator}s rather than
3546 objects of specific access types. It seems unlikely that any program depending
3547 on this restriction would violate it in this blatant manner, so it is expected
3548 that very few programs will be affected by this change.]}
3549
3550 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0211-1]}
3551 @ChgAdded{Version=[3],Text=[@b<Correction:>
3552 The restriction No_Relative_Delay was changed to include the Timing_Events
3553 routine that uses a relative delay. This means that a program that uses
3554 that routine and this restriction will now be rejected. However, such a
3555 program violates the spirit and intent of the restriction and as such the
3556 program should never have been allowed. Moreover, it is unlikely that
3557 any program depending on this restriction would violate it in such an obvious
3558 manner, so it is expected that very few programs will be affected by this
3559 change.]}
3560
3561 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0211-1]}
3562 @ChgAdded{Version=[3],Text=[@b<Correction:> A number of restrictions were
3563 changed from "no calls" on some subprogram to "no use of a @nt{name} that
3564 denotes" that subprogram. This closes a hole where renames, uses as the prefix
3565 of 'Access, and the like, would not be rejected by the restriction, possibly
3566 allowing backdoor access to the prohibited subprogram. A program that
3567 uses one of these restrictions and using such backdoor access will now be
3568 rejected; however, it is extremely unlikely that any program that relies
3569 on these restrictions would also use an end-run around the restriction, so
3570 it is expected that very few programs will be affected by this change.]}
3571 @end{Incompatible2005}
3572
3573 @begin{Extend2005}
3574 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0189-1]}
3575 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
3576 Restriction No_Standard_Allocators_After_Elaboration is newly
3577 added to Ada.]}
3578 @end{Extend2005}
3579
3580 @begin{DiffWord2005}
3581 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0013-1],ARef=[AI05-0216-1]}
3582 @ChgAdded{Version=[3],Text=[@b<Correction:> Improved the wording
3583 of various restrictions to make it clearer that they prohibit
3584 things that would otherwise be legal, and to word them as
3585 definitions, not @LegalityTitle;.]}
3586
3587 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0192-1]}
3588 @ChgAdded{Version=[3],Text=[@b<Correction:> Added wording to explain
3589 how No_Task_Allocators and No_Protected_Type_Allocators are checked
3590 for class-wide types. This might be an extension if the compiler
3591 assumed the worst in the past (it is now a runtime check).]}
3592 @end{DiffWord2005}
3593
3594 @begin{Extend2012}
3595 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0055-1]}
3596 @ChgAdded{Version=[4],Text=[@Defn{extensions to Ada 2012}
3597 @b{Corrigendum:} Restriction No_Dynamic_CPU_Assignment is newly
3598 added to Ada, for use as part of the Ravenscar profile
3599 (see @RefSecNum{The Ravenscar Profile}).]}
3600
3601 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0117-1]}
3602 @ChgAdded{Version=[4],Text=[@b{Corrigendum:} Restriction
3603 No_Tasks_Unassigned_To_CPU is newly added to Ada; it ensures that no
3604 task is running on an implementation-defined CPU so that task scheduling
3605 can be analyzed.]}
3606 @end{Extend2012}
3607
3608
3609
3610 @LabeledClause{Monotonic Time}
3611 @begin{Intro}
3612 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3613 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
3614 a high-resolution, monotonic clock package.]
3615 @end{Intro}
3616
3617 @begin{StaticSem}
3618 @Leading@;The following language-defined library package exists:
3619 @begin{example}
3620 @key[package] Ada.Real_Time @key[is]@ChildUnit{Parent=[Ada],Child=[Real_Time]}
3621
3622 @key[type] @AdaTypeDefn{Time} @key[is] @key[private];
3623 @AdaObjDefn{Time_First} : @key[constant] Time;
3624 @AdaObjDefn{Time_Last} : @key[constant] Time;
3625 @AdaObjDefn{Time_Unit} : @key[constant] := @RI{implementation-defined-real-number};
3626
3627
3628
3629 @key[type] @AdaTypeDefn{Time_Span} @key[is] @key[private];
3630 @AdaObjDefn{Time_Span_First} : @key[constant] Time_Span;
3631 @AdaObjDefn{Time_Span_Last} : @key[constant] Time_Span;
3632 @AdaObjDefn{Time_Span_Zero} : @key[constant] Time_Span;
3633 @AdaObjDefn{Time_Span_Unit} : @key[constant] Time_Span;
3634
3635
3636 @AdaObjDefn{Tick} : @key[constant] Time_Span;
3637 @key[function] @AdaSubDefn{Clock} @key[return] Time;
3638
3639
3640 @key[function] "+" (Left : Time; Right : Time_Span) @key[return] Time;
3641 @key[function] "+" (Left : Time_Span; Right : Time) @key[return] Time;
3642 @key[function] "-" (Left : Time; Right : Time_Span) @key[return] Time;
3643 @key[function] "-" (Left : Time; Right : Time) @key[return] Time_Span;
3644
3645
3646 @key[function] "<" (Left, Right : Time) @key[return] Boolean;
3647 @key[function] "<="(Left, Right : Time) @key[return] Boolean;
3648 @key[function] ">" (Left, Right : Time) @key[return] Boolean;
3649 @key[function] ">="(Left, Right : Time) @key[return] Boolean;
3650
3651
3652 @key[function] "+" (Left, Right : Time_Span) @key[return] Time_Span;
3653 @key[function] "-" (Left, Right : Time_Span) @key[return] Time_Span;
3654 @key[function] "-" (Right : Time_Span) @key[return] Time_Span;
3655 @key[function] "*" (Left : Time_Span; Right : Integer) @key{return} Time_Span;
3656 @key[function] "*" (Left : Integer; Right : Time_Span) @key{return} Time_Span;
3657 @key[function] "/" (Left, Right : Time_Span) @key[return] Integer;
3658 @key[function] "/" (Left : Time_Span; Right : Integer) @key[return] Time_Span;
3659
3660 @key[function] "@key[abs]"(Right : Time_Span) @key[return] Time_Span;
3661
3662 @ChgRef{Version=[1], Kind=[Deleted]}
3663 @Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number from original RM}>]
3664
3665 @key[function] "<" (Left, Right : Time_Span) @key[return] Boolean;
3666 @key[function] "<="(Left, Right : Time_Span) @key[return] Boolean;
3667 @key[function] ">" (Left, Right : Time_Span) @key[return] Boolean;
3668 @key[function] ">="(Left, Right : Time_Span) @key[return] Boolean;
3669
3670
3671 @key[function] @AdaSubDefn{To_Duration} (TS : Time_Span) @key[return] Duration;
3672 @key[function] @AdaSubDefn{To_Time_Span} (D : Duration) @key[return] Time_Span;
3673
3674
3675 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00386-01]}
3676 @key[function] @AdaSubDefn{Nanoseconds} (NS : Integer) @key{return} Time_Span;
3677 @key[function] @AdaSubDefn{Microseconds} (US : Integer) @key{return} Time_Span;
3678 @key[function] @AdaSubDefn{Milliseconds} (MS : Integer) @key{return} Time_Span;@Chg{Version=[2],New=[
3679 @key[function] @AdaSubDefn{Seconds} (S : Integer) @key{return} Time_Span;
3680 @key[function] @AdaSubDefn{Minutes} (M : Integer) @key{return} Time_Span;],Old=[]}
3681
3682
3683 @key[type] @AdaTypeDefn{Seconds_Count} @key[is] @key[range] @RI{implementation-defined};
3684
3685 @key{procedure} @AdaSubDefn{Split}(T : @key{in} Time; SC : @key{out} Seconds_Count; TS : @key{out} Time_Span);
3686 @key{function} @AdaSubDefn{Time_Of}(SC : Seconds_Count; TS : Time_Span) @key{return} Time;
3687
3688 @key[private]
3689 ... -- @RI{not specified by the language}
3690 @key[end] Ada.Real_Time;
3691 @end{example}
3692 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
3693 Text=[@ChgDeleted{Version=[2],
3694 Text=[Implementation-defined aspects of package Real_Time.]}]}
3695
3696 @Defn{real time}
3697 In this Annex, @i{real time} is defined to be the physical time as observed
3698 in the external environment.
3699 The type Time is a @i{time type} as defined by
3700 @RefSecNum{Delay Statements, Duration, and Time};
3701 @Redundant[values of this type may be used in a
3702 @nt{delay_until_statement}.]
3703 Values of this type
3704 represent segments of an ideal time line. The set of values of
3705 the type Time corresponds one-to-one with an
3706 implementation-defined range of mathematical integers.
3707 @begin{Discussion}
3708 Informally, real time is defined to be the International Atomic Time (TAI)
3709 which is monotonic and nondecreasing. We use it here for the purpose of
3710 discussing rate of change and monotonic behavior only. It does not imply
3711 anything about the absolute value of Real_Time.Clock, or about Real_Time.Time
3712 being synchronized with TAI. It is also used for real time in the metrics,
3713 for comparison purposes.
3714 @end{Discussion}
3715 @begin{ImplNote}
3716 The specification of TAI as @lquotes@;real time@rquotes@; does not preclude the
3717 use of a simulated TAI clock for simulated execution environments.
3718 @end{ImplNote}
3719
3720 @Defn{epoch}
3721 @PDefn{unspecified}
3722 The Time value I represents the half-open real time
3723 interval that starts with E+I*Time_Unit and is limited by E+(I+1)*Time_Unit,
3724 where Time_Unit is an implementation-defined real number and E is an
3725 unspecified origin point, the @i{epoch}, that is the same
3726 for all values of the type Time.
3727 It is not specified by the language whether the time values are
3728 synchronized with any standard time reference.
3729 @Redundant[For example, E can correspond to the time of system
3730 initialization or it can correspond to the epoch of some time standard.]
3731 @begin{Discussion}
3732 E itself does not have to be a proper time value.
3733
3734 This half-open interval I consists of all
3735 real numbers R such that E+I*Time_Unit <= R < E+(I+1)*Time_Unit.
3736 @end{Discussion}
3737
3738 Values of the type Time_Span represent length of real time
3739 duration.
3740 The set of values of this type corresponds one-to-one
3741 with an implementation-defined range of mathematical integers.
3742 The Time_Span value corresponding to the integer I
3743 represents the real-time duration I*Time_Unit.
3744 @begin{Reason}
3745 The purpose of this type is similar to Standard.Duration; the idea is to
3746 have a type with a higher resolution.
3747 @end{Reason}
3748 @begin{Discussion}
3749 We looked at many possible names for this type: Real_Time.Duration,
3750 Fine_Duration, Interval, Time_Interval_Length, Time_Measure, and more.
3751 Each of these names had some problems, and we've finally settled for Time_Span.
3752 @end{Discussion}
3753
3754 Time_First and Time_Last are the smallest and largest values of the
3755 Time type, respectively.
3756 Similarly, Time_Span_First and Time_Span_Last are the smallest and
3757 largest values of the Time_Span type, respectively.
3758
3759 A value of type Seconds_Count represents an elapsed time,
3760 measured in seconds,
3761 since the epoch.
3762
3763 @end{StaticSem}
3764
3765 @begin{RunTime}
3766
3767 Time_Unit is the smallest amount of real time representable by the Time type;
3768 it is expressed in seconds. Time_Span_Unit is the difference between
3769 two successive values of the Time type. It is also the smallest positive
3770 value of type Time_Span. Time_Unit and Time_Span_Unit represent
3771 the same real time duration.
3772 @Defn{clock tick}
3773 A @i{clock tick} is a real time interval during
3774 which the clock value (as observed by calling the Clock function) remains
3775 constant. Tick is the average length of such intervals.
3776
3777 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00432-01]}
3778 The function To_Duration converts the value TS to a value of type
3779 Duration. Similarly, the function To_Time_Span converts the value D
3780 to a value of type Time_Span. For @Chg{Version=[2],New=[To_Duration],
3781 Old=[both operations]}, the result is
3782 rounded to the nearest @Chg{Version=[2],New=[value of type Duration],
3783 Old=[exactly representable value]} (away from zero if exactly
3784 halfway between two @Chg{Version=[2],New=[],
3785 Old=[exactly representable ]}values).@Chg{Version=[2],New=[ If the result
3786 is outside the range of Duration, Constraint_Error is raised. For To_Time_Span,
3787 the value of D is first rounded to the nearest integral multiple of Time_Unit,
3788 away from zero if exactly halfway between two multiples. If the
3789 rounded value is outside the range of Time_Span, Constraint_Error is
3790 raised. Otherwise, the value is converted to the type Time_Span.],Old=[]}
3791
3792 To_Duration(Time_Span_Zero) returns 0.0,
3793 and To_Time_Span(0.0) returns Time_Span_Zero.
3794
3795 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00386-01],ARef=[AI95-00432-01]}
3796 The functions Nanoseconds, Microseconds, @Chg{Version=[2],New=[],
3797 Old=[and ]}Milliseconds@Chg{Version=[2],New=[, Seconds, and Minutes],Old=[]}
3798 convert the input
3799 parameter to a value of the type Time_Span. NS, US,@Chg{Version=[2],New=[],Old=[ and]}
3800 MS@Chg{Version=[2],New=[, S, and M],Old=[]} are interpreted as a number of
3801 nanoseconds, microseconds,@Chg{Version=[2],New=[],Old=[ and]}
3802 milliseconds@Chg{Version=[2],New=[, seconds, and minutes],Old=[]}
3803 respectively.@Chg{Version=[2],New=[ The input parameter is first converted to
3804 seconds and rounded to the nearest integral multiple of Time_Unit, ],
3805 Old=[The result is rounded to the nearest exactly
3806 representable value (]}away from zero if exactly halfway between two
3807 @Chg{Version=[2],New=[multiples. If the rounded value
3808 is outside the range of Time_Span, Constraint_Error is raised.
3809 Otherwise, the rounded value is converted to the type Time_Span],
3810 Old=[exactly representable values)]}.
3811 @begin{Discussion}
3812 @ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00432-01]}
3813 @ChgDeleted{Version=[2],Text=[The above does not imply that the Time_Span
3814 type will have to accommodate Integer'Last of milliseconds; Constraint_Error
3815 is allowed to be raised.]}
3816 @end{Discussion}
3817
3818 The effects of the operators on Time and Time_Span are as for the
3819 operators defined for integer types.
3820 @begin{ImplNote}
3821 Though time values are modeled by integers, the types Time and
3822 Time_Span need not be implemented as integers.
3823 @end{ImplNote}
3824
3825 The function Clock returns
3826 the amount of time since the epoch.
3827
3828 The effects of the Split and Time_Of operations are defined as follows,
3829 treating values of type
3830 Time, Time_Span, and Seconds_Count as mathematical integers.
3831 The effect of Split(T,SC,TS) is to set SC and TS to values
3832 such that T*Time_Unit = SC*1.0 + TS*Time_Unit, and 0.0 <= TS*Time_Unit < 1.0.
3833 The value returned by Time_Of(SC,TS) is the value T such that T*Time_Unit =
3834 SC*1.0 + TS*Time_Unit.
3835 @end{RunTime}
3836
3837 @begin{ImplReq}
3838
3839 The range of Time values shall be sufficient to uniquely
3840 represent the range of real times from program start-up to 50 years later.
3841 Tick shall be no greater than 1 millisecond.
3842 Time_Unit shall be less than or equal to 20 microseconds.
3843 @begin{ImplNote}
3844 The required range and accuracy of Time are such that
3845 32-bits worth of seconds and 32-bits worth of ticks in a second could be
3846 used as the representation.
3847 @end{ImplNote}
3848
3849 Time_Span_First shall be no greater than @en@;3600 seconds, and
3850 Time_Span_Last shall be no less than 3600 seconds.
3851 @begin{Reason}
3852 This is equivalent to @PorM one hour and there is still room for
3853 a two-microsecond resolution.
3854 @end{Reason}
3855
3856 @Defn{clock jump}
3857 A @i{clock jump} is the difference between two successive distinct values of
3858 the clock (as observed by calling the Clock function). There shall be no
3859 backward clock jumps.
3860
3861 @end{ImplReq}
3862
3863 @begin{DocReq}
3864
3865 The implementation shall document the values of Time_First, Time_Last,
3866 Time_Span_@!First, Time_Span_@!Last, Time_Span_@!Unit, and Tick.
3867 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3868 Text=[The values of Time_First, Time_Last,
3869 Time_Span_@!First, Time_Span_@!Last, Time_Span_@!Unit, and Tick
3870 for package Real_Time.]}]}
3871
3872 The implementation shall document the properties of the underlying
3873 time base used for the clock and for type Time,
3874 such as the range of values supported
3875 and any relevant aspects of the underlying hardware
3876 or operating system facilities used.
3877 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3878 Text=[The properties of the underlying
3879 time base used in package Real_Time.]}]}
3880 @begin{Discussion}
3881 If there is an underlying operating system,
3882 this might include information about which system call is used
3883 to implement the clock.
3884 Otherwise, it might include information about which
3885 hardware clock is used.
3886 @end{Discussion}
3887
3888 The implementation shall document whether or not there is any synchronization
3889 with external time references, and if such synchronization exists, the sources
3890 of synchronization information, the frequency of synchronization, and the
3891 synchronization method applied.
3892 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3893 Text=[Any synchronization of package Real_Time with external time references.]}]}
3894
3895 @ChgRef{Version=[1],Kind=[Revised]}
3896 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3897 The implementation shall document any aspects of the @Chg{New=[], Old=[the]}
3898 @chgnote{Correct typo as noted at Potsdam ARG meeting}
3899 external environment that could interfere with the clock behavior as defined
3900 in this @Chg{Version=[3],New=[subclause],Old=[clause]}.
3901 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3902 Text=[Any aspects of the external environment that could interfere with
3903 package Real_Time.]}]}
3904 @begin{Discussion}
3905 For example, the implementation is allowed to rely on the time services of
3906 an underlying operating system, and this operating system clock can
3907 implement time zones or allow the clock to be reset by an operator.
3908 This dependence has to be documented.
3909 @end{Discussion}
3910 @end{DocReq}
3911
3912 @begin{Metrics}
3913 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3914 For the purpose of the metrics defined in this @Chg{Version=[3],New=[subclause],Old=[clause]},
3915 real time is defined to be the International Atomic Time (TAI).
3916
3917 @Leading@;The implementation shall document the following metrics:
3918 @begin{Itemize}
3919 An upper bound on the real-time duration of a clock tick. This is a value
3920 D such that if t1 and t2 are any real times such that t1 < t2 and
3921 Clock@-{t1} = Clock@-{t2} then t2 @en@; t1 <= D.
3922
3923 An upper bound on the size of a clock jump.
3924
3925 @Defn{drift rate}
3926 An upper bound on the @i{drift rate} of Clock with respect to real time.
3927 This is a real number D such that
3928 @begin{display}
3929 E*(1@en@;D) <= (Clock@-{t+E} @en@; Clock@-{t}) <= E*(1+D)
3930 provided that: Clock@-{t} + E*(1+D) <= Time_Last.
3931 @end{display}
3932
3933 where Clock@-{t} is the value of Clock at time t, and E is a real
3934 time duration not less than 24 hours. The value of E used for
3935 this metric shall be reported.
3936 @begin{Reason}
3937 This metric is intended to provide a measurement
3938 of the long term (cumulative) deviation; therefore, 24
3939 hours is the
3940 lower bound on the measurement period. On some implementations,
3941 this is also the maximum period, since the language does not
3942 require that the range of the type Duration be more than 24 hours.
3943 On those implementations that support longer-range Duration, longer
3944 measurements should be performed.
3945 @end{Reason}
3946
3947 An upper bound on the execution time of a call to the Clock
3948 function, in processor clock cycles.
3949
3950 Upper bounds on the execution times of the operators of the types Time
3951 and Time_Span, in processor clock cycles.
3952 @begin{ImplNote}
3953 A fast implementation of the Clock function involves repeated
3954 reading until you get the same value twice.
3955 It is highly improbable that more than three reads will be necessary.
3956 Arithmetic on time values should not be significantly slower
3957 than 64-bit arithmetic in the underlying machine instruction set.
3958 @end{ImplNote}
3959 @end{Itemize}
3960 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3961 Text=[The metrics for package Real_Time.]}]}
3962 @end{Metrics}
3963
3964 @begin{ImplPerm}
3965 Implementations targeted to machines with word size smaller than 32
3966 bits need not support the full range and granularity of the
3967 Time and Time_Span types.
3968 @begin{Discussion}
3969 These requirements are based on machines with a word size of 32 bits.
3970
3971 Since the range and granularity are implementation defined, the supported
3972 values need to be documented.
3973 @end{Discussion}
3974 @end{ImplPerm}
3975
3976 @begin{ImplAdvice}
3977
3978 When appropriate, implementations should provide configuration mechanisms to
3979 change the value of Tick.
3980 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
3981 Text=[When appropriate, mechanisms to change the value of Tick should be
3982 provided.]}]}
3983 @begin{Reason}
3984 This is often needed when the compilation system was originally targeted to a
3985 particular processor with a particular interval timer, but the customer
3986 uses the same processor with a different interval timer.
3987 @end{Reason}
3988 @begin{Discussion}
3989 Tick is a deferred constant and not a named number
3990 specifically for this purpose.
3991 @end{Discussion}
3992 @begin{ImplNote}
3993 This can be achieved either by pre-run-time configuration
3994 tools, or by having Tick be initialized
3995 (in the package private part)
3996 by a function call residing in a board specific module.
3997 @end{ImplNote}
3998
3999 It is recommended that Calendar.Clock and Real_Time.Clock be implemented
4000 as transformations of the same time base.
4001 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
4002 Text=[Calendar.Clock and Real_Time.Clock should be transformations of the
4003 same time base.]}]}
4004
4005 It is recommended that the @lquotes@;best@rquotes@; time base which exists in the
4006 underlying system be available to the application through
4007 Clock. @lquotes@;Best@rquotes@; may mean highest accuracy or largest range.
4008 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
4009 Text=[The @lquotes@;best@rquotes@; time base which exists in the
4010 underlying system should be available to the application through
4011 Real_Time.Clock.]}]}
4012
4013 @end{ImplAdvice}
4014
4015 @begin{Notes}
4016
4017 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4018 The rules in this @Chg{Version=[3],New=[subclause],Old=[clause]} do not imply
4019 that the implementation can protect the user from operator or installation
4020 errors which could result in the clock being set incorrectly.
4021
4022 Time_Unit is the granularity of the Time type. In contrast,
4023 Tick represents the granularity of Real_Time.Clock.
4024 There is no requirement that these be the same.
4025
4026 @end{Notes}
4027
4028 @begin{Incompatible95}
4029 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00386-01]}
4030 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
4031 @ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
4032 Functions Seconds and Minutes are @Chg{Version=[3],New=[],Old=[newly ]}added
4033 to Real_Time. If
4034 Real_Time is referenced in a @nt{use_clause}, and an entity @i<E> with a
4035 @nt{defining_identifier} of Seconds or Minutes is defined in a package that
4036 is also referenced in a @nt{use_clause}, the entity @i<E> may no longer be
4037 use-visible, resulting in errors. This should be rare and is easily fixed if
4038 it does occur.]}
4039 @end{Incompatible95}
4040
4041 @begin{DiffWord95}
4042 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00432-01]}
4043 @ChgAdded{Version=[2],Text=[Added wording explaining how and when many of
4044 these functions can raise Constraint_Error. While there always was an
4045 intent to raise Constraint_Error if the values did not fit, there never
4046 was any wording to that effect, and since Time_Span was a private type,
4047 the normal numeric type rules do not apply to it.]}
4048 @end{DiffWord95}
4049
4050
4051 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
4052 @LabeledClause{Delay Accuracy}
4053
4054 @begin{Intro}
4055 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4056 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} specifies
4057 performance requirements for the @nt{delay_statement}.
4058 The rules apply both to @nt{delay_@!relative_@!statement} and to
4059 @nt{delay_@!until_@!statement}. Similarly, they apply equally to a
4060 simple @nt{delay_@!statement} and to one which appears in a
4061 @nt{delay_@!alternative}.]
4062 @end{Intro}
4063
4064 @begin{RunTime}
4065 @Leading@;The effect of the @nt{delay_statement} for Real_Time.Time is
4066 defined in terms of Real_Time.Clock:
4067 @begin{itemize}
4068
4069 If C@-{1} is a value of Clock read before a task executes a
4070 @nt{delay_relative_statement} with duration D, and C@-{2} is a value of
4071 Clock read after the task resumes execution following that
4072 @nt{delay_statement}, then C@-{2} @en@; C@-{1} >= D.
4073
4074 If C is a value of Clock read after a task resumes execution following a
4075 @nt{delay_until_statement} with Real_Time.Time value T, then C >= T.
4076 @end{itemize}
4077
4078 @PDefn2{Term=[potentially blocking operation],Sec=(delay_statement)}
4079 @PDefn2{Term=[blocking, potentially],Sec=(delay_statement)}
4080 A simple @nt{delay_statement} with a negative or zero value for the
4081 expiration time does not cause the calling task to be blocked; it is
4082 nevertheless a potentially blocking operation
4083 (see @RefSecNum{Protected Subprograms and Protected Actions}).
4084
4085 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0004-1]}
4086 When a @nt{delay_statement} appears in a @nt{delay_alternative} of a
4087 @nt{timed_entry_call} the selection of the entry call is attempted,
4088 regardless of the specified expiration time.
4089 When a @nt{delay_statement} appears in a
4090 @Chg{Version=[3],New=[@nt{select_alternative}],Old=[@ntf{selective_accept_alternative}]},
4091 and a call is queued on one of the open entries, the selection of that
4092 entry call proceeds, regardless of the value of the delay expression.
4093 @begin{Ramification}
4094 The effect of these requirements is that one has to always attempt a rendezvous,
4095 regardless of the value of the delay expression. This can be tested by
4096 issuing a @nt{timed_entry_call} with an expiration time
4097 of zero, to an open entry.
4098 @end{Ramification}
4099
4100 @end{RunTime}
4101
4102 @begin{DocReq}
4103
4104 The implementation shall document the minimum value of the delay expression
4105 of a @nt{delay_relative_statement} that causes the task to actually be blocked.
4106 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4107 Text=[The minimum value of the delay expression of a
4108 @nt{delay_relative_statement} that causes a task to actually be blocked.]}]}
4109
4110 The implementation shall document the minimum difference between the value of
4111 the delay expression of a @nt{delay_until_statement} and the value of
4112 Real_Time.Clock, that causes the task to actually be blocked.
4113 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
4114 Text=[@ChgDeleted{Version=[2],
4115 Text=[Implementation-defined aspects of @nt{delay_statement}s.]}]}
4116 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4117 Text=[The minimum difference between the value of the delay expression of a
4118 @nt{delay_until_statement} and the value of Real_Time.Clock, that causes the
4119 task to actually be blocked.]}]}
4120
4121 @end{DocReq}
4122
4123 @begin{Metrics}
4124 @Leading@;The implementation shall document the following metrics:
4125 @begin{Itemize}
4126 An upper bound on the execution time, in processor clock cycles, of a
4127 @nt{delay_relative_statement} whose requested value of the delay expression
4128 is less than or equal to zero.
4129
4130 An upper bound on the execution time, in processor clock cycles, of a
4131 @nt{delay_until_statement} whose requested value of the delay expression is
4132 less than or equal to the value of Real_Time.Clock at the
4133 time of executing the statement. Similarly, for Calendar.Clock.
4134
4135 @Defn{lateness}
4136 @Defn{actual duration}
4137 An upper bound on the @i{lateness} of a @nt{delay_relative_statement},
4138 for a positive value of the delay expression, in a situation
4139 where the task has sufficient priority to preempt the processor as
4140 soon as it becomes ready, and does not need to
4141 wait for any other execution resources. The upper bound is
4142 expressed as a function of the value of the delay expression.
4143 The lateness is obtained by subtracting the value of the delay expression
4144 from the @i{actual duration}. The actual duration is measured from a point
4145 immediately before a task executes the @nt{delay_statement} to a point
4146 immediately after the task resumes execution following this statement.
4147
4148 An upper bound on the lateness of a @nt{delay_until_statement}, in a
4149 situation where the value of the requested expiration time is after the time
4150 the task begins executing the statement, the task has sufficient priority
4151 to preempt the processor as soon as it becomes ready, and
4152 it does not need to wait for any other execution resources. The upper
4153 bound is expressed as a function of the difference between the requested
4154 expiration time and the clock value at the time the statement begins
4155 execution. The lateness of a @nt{delay_until_statement} is obtained by
4156 subtracting the requested expiration time from the real time that the task
4157 resumes execution following this statement.
4158 @end{Itemize}
4159 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4160 Text=[The metrics for delay statements.]}]}
4161 @end{Metrics}
4162
4163 @begin{Notes}
4164
4165 @ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00355-01]}
4166 @ChgDeleted{Version=[2],Text=[The execution time of a @nt{delay_statement} that
4167 does not cause the task to be blocked (e.g. @lquotes@;@key[delay]
4168 0.0;@rquotes@; ) is of interest in situations where delays are used to achieve
4169 voluntary round-robin task dispatching among equal-priority tasks.]}
4170
4171 @end{Notes}
4172
4173 @begin{DiffWord83}
4174
4175 The rules regarding a @nt{timed_entry_call} with a very small positive
4176 Duration value, have been tightened to always require the check whether
4177 the rendezvous is immediately possible.
4178
4179 @end{DiffWord83}
4180
4181 @begin{DiffWord95}
4182
4183 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00355-01]}
4184 @ChgAdded{Version=[2],Text=[The note about @lquotes@;voluntary
4185 round-robin@rquote, while still true, has been deleted as potentially
4186 confusing as it is describing a different kind of round-robin than is defined
4187 by the round-robin dispatching policy.]}
4188
4189 @end{DiffWord95}
4190
4191
4192 @LabeledClause{Synchronous Task Control}
4193
4194 @begin{Intro}
4195 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4196 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} describes
4197 a language-defined private semaphore
4198 (suspension object), which can be used for @i{two-stage suspend}
4199 operations and as a simple building block for implementing higher-level
4200 queues.]
4201 @end{Intro}
4202
4203 @begin{StaticSem}
4204
4205 @Leading@;The following language-defined package exists:
4206 @begin{example}
4207 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]}
4208 @key{package} Ada.Synchronous_Task_Control @key{is}@ChildUnit{Parent=[Ada],Child=[Synchronous_Task_Control]}@Chg{Version=[2],New=[
4209 @key[pragma] Preelaborate(Synchronous_Task_Control);],Old=[]}
4210
4211 @key{type} @AdaTypeDefn{Suspension_Object} @key{is} @key{limited} @key{private};
4212 @key{procedure} @AdaSubDefn{Set_True}(S : @key{in} @key{out} Suspension_Object);
4213 @key{procedure} @AdaSubDefn{Set_False}(S : @key{in} @key{out} Suspension_Object);
4214 @key{function} @AdaSubDefn{Current_State}(S : Suspension_Object) @key{return} Boolean;
4215 @key{procedure} @AdaSubDefn{Suspend_Until_True}(S : @key{in} @key{out} Suspension_Object);
4216 @key{private}
4217 ... -- @RI{not specified by the language}
4218 @key{end} Ada.Synchronous_Task_Control;
4219 @end{example}
4220
4221 The type Suspension_Object is a by-reference type.@begin{ImplNote}
4222 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00318-02]}@ChgNote{This is a real term now, let's get it right}
4223 The implementation can ensure this by, for example, making the full view
4224 @Chg{Version=[2],New=[an explicitly],Old=[a]}
4225 limited record type.@end{implnote}
4226
4227 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0168-1]}
4228 @ChgAdded{Version=[3],Type=[Leading],Text=[The following language-defined package
4229 exists:]}
4230 @begin{example}
4231 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0168-1]}
4232 @ChgAdded{Version=[3],Text=[@key{package} Ada.Synchronous_Task_Control.EDF @key{is}@ChildUnit{Parent=[Ada.Synchronous_Task_Control],Child=[EDF]}
4233 @key{procedure} @AdaSubDefn{Suspend_Until_True_And_Set_Deadline}
4234 (S : @key{in out} Suspension_Object;
4235 TS : @key{in} Ada.Real_Time.Time_Span);
4236 @key{end} Ada.Synchronous_Task_Control.EDF;]}
4237 @end{example}
4238
4239 @end{StaticSem}
4240
4241 @begin{RunTime}
4242
4243 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
4244 An object of the type Suspension_Object has two visible states:
4245 @Chg{Version=[2],New=[True],Old=[true]} and
4246 @Chg{Version=[2],New=[False],Old=[false]}. Upon initialization,
4247 its value is set to @Chg{Version=[2],New=[False],Old=[false]}.
4248 @begin{Discussion}
4249 This object is assumed to be private to the declaring task, i.e. only that
4250 task will call Suspend_Until_True on this object, and the count of callers is
4251 at most one. Other tasks can, of course, change and query the state of this
4252 object.
4253 @end{Discussion}
4254
4255 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
4256 The operations Set_True and Set_False are atomic with respect to each other
4257 and with respect to Suspend_Until_True; they set the state to
4258 @Chg{Version=[2],New=[True],Old=[true]} and
4259 @Chg{Version=[2],New=[False],Old=[false]} respectively.
4260
4261 Current_State returns the current state of the object.
4262 @begin{Discussion}
4263 This state can change immediately after the operation returns.
4264 @end{Discussion}
4265
4266 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
4267 The procedure Suspend_Until_True blocks the calling task until the
4268 state of the object S is @Chg{Version=[2],New=[True],Old=[true]}; at that
4269 point the task becomes ready
4270 and the state of the object becomes @Chg{Version=[2],New=[False],Old=[false]}.
4271
4272 @PDefn2{Term=[potentially blocking operation],Sec=(Suspend_Until_True)}
4273 @PDefn2{Term=[blocking, potentially],Sec=(Suspend_Until_True)}
4274 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
4275 Program_Error is raised upon calling Suspend_Until_True if another
4276 task is already waiting on that suspension object.
4277 Suspend_Until_True is a potentially blocking operation
4278 (see @RefSecNum{Protected Subprograms and Protected Actions}).
4279
4280 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0168-1],ARef=[AI05-0269-1]}
4281 @ChgAdded{Version=[3],Text=[The procedure Suspend_Until_True_And_Set_Deadline
4282 blocks the calling task until the state of the object S is True; at that point
4283 the task becomes ready with a deadline of Ada.Real_Time.Clock + TS, and the
4284 state of the object becomes False. Program_Error is raised upon calling
4285 Suspend_Until_True_And_Set_Deadline if another task is already waiting on that
4286 suspension object. Suspend_Until_True_And_Set_Deadline is a potentially blocking
4287 operation.]}
4288 @end{RunTime}
4289
4290 @begin{ImplReq}
4291
4292 The implementation is required to allow the calling of Set_False and
4293 Set_True during any protected action, even one that has its ceiling priority
4294 in the Interrupt_Priority range.
4295
4296 @end{ImplReq}
4297
4298 @begin{Notes}
4299 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0168-1]}
4300 @ChgAdded{Version=[3],Text=[More complex schemes, such as setting the deadline
4301 relative to when Set_True is called, can be programmed using a protected
4302 object.]}
4303 @end{Notes}
4304
4305 @begin{Extend95}
4306 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
4307 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
4308 Synchronous_Task_Control is now Preelaborated,
4309 so it can be used in preelaborated units.]}
4310 @end{Extend95}
4311
4312 @begin{Extend2005}
4313 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0168-1]}
4314 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}Child
4315 package Ada.Synchronous_Task_Control.EDF is new.]}
4316 @end{Extend2005}
4317
4318
4319 @LabeledAddedSubClause{Version=[3],Name=[Synchronous Barriers]}
4320
4321 @begin{Intro}
4322 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1],ARef=[AI05-0299-1]}
4323 @ChgAdded{Version=[3],Text=[This subclause introduces a language-defined package to
4324 synchronously release a group of tasks after the number of blocked tasks reaches
4325 a specified count value.]}
4326 @end{Intro}
4327
4328 @begin{StaticSem}
4329
4330 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4331 @ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The following
4332 language-defined library package exists:]}
4333 @begin{Example}
4334 @ChgRef{Version=[3],Kind=[AddedNormal]}
4335 @ChgAdded{Version=[3],Text=[@key[package] Ada.Synchronous_Barriers @key{is}@ChildUnit{Parent=[Ada],Child=[Synchronous_Barriers]}
4336 @key[pragma] Preelaborate(Synchronous_Barriers);]}
4337
4338 @ChgRef{Version=[3],Kind=[AddedNormal]}
4339 @ChgAdded{Version=[3],Text=[ @key[subtype] @AdaSubtypeDefn{Name=[Barrier_Limit],Of=[Positive]} @key[is] Positive @key[range] 1 .. @RI<implementation-defined>;]}
4340 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
4341 Text=[The value of Barrier_Limit'Last in Synchronous_Barriers.]}]}
4342
4343 @ChgRef{Version=[3],Kind=[AddedNormal]}
4344 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Synchronous_Barrier} (Release_Threshold : Barrier_Limit) @key[is limited private];]}
4345
4346 @ChgRef{Version=[3],Kind=[AddedNormal]}
4347 @ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Wait_For_Release} (The_Barrier : @key[in out] Synchronous_Barrier;
4348 Notified : @key[out] Boolean);]}
4349
4350 @ChgRef{Version=[3],Kind=[AddedNormal]}
4351 @ChgAdded{Version=[3],Text=[@key[private]
4352 -- @RI{not specified by the language}
4353 @key[end] Ada.Synchronous_Barriers;]}
4354 @end{Example}
4355
4356 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4357 @ChgAdded{Version=[3],Text=[Type Synchronous_Barrier needs finalization (see
4358 @RefSecNum{Assignment and Finalization}).]}
4359 @end{StaticSem}
4360
4361 @begin{Runtime}
4362
4363 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4364 @ChgAdded{Version=[3],Text=[Each call to Wait_For_Release blocks the calling
4365 task until the number of blocked tasks associated with the Synchronous_Barrier
4366 object is equal to Release_Threshold, at which time all blocked tasks are released.
4367 Notified is set to True for one of the released tasks, and set to False for all
4368 other released tasks.]}
4369
4370 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4371 @ChgAdded{Version=[3],Text=[The mechanism for determining which task sets
4372 Notified to True is implementation defined.]}
4373
4374 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4375 @ChgAdded{Version=[3],Text=[Once all tasks have been released, a
4376 Synchronous_Barrier object may be reused to block another Release_Threshold number
4377 of tasks.]}
4378
4379 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4380 @ChgAdded{Version=[3],Text=[As the first step of the finalization of a
4381 Synchronous_Barrier, each blocked task is unblocked and Program_Error is raised
4382 at the place of the call to Wait_For_Release.]}
4383
4384 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4385 @ChgAdded{Version=[3],Text=[It is implementation defined whether an abnormal
4386 task which is waiting on a Synchronous_Barrier object is aborted immediately or
4387 aborted when the tasks waiting on the object are released.]}
4388 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
4389 Text=[When an aborted task that is waiting on a Synchronous_Barrier is aborted.]}]}
4390
4391 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4392 @ChgAdded{Version=[3],Text=[Wait_For_Release is a potentially blocking operation
4393 (see @RefSecNum{Protected Subprograms and Protected Actions}).]}
4394 @end{Runtime}
4395
4396 @begin{Bounded}
4397 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4398 @ChgAdded{Version=[3],Text=[It is a bounded error to call Wait_For_Release on a
4399 Synchronous_Barrier object after that object is finalized. If the error is
4400 detected, Program_Error is raised. Otherwise, the call proceeds normally, which
4401 may leave a task blocked forever.]}
4402 @end{Bounded}
4403
4404
4405 @begin{Extend2005}
4406 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0174-1]}
4407 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
4408 The package Ada.Synchronous_Barriers is new.]}
4409 @end{Extend2005}
4410
4411
4412
4413 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
4414 @LabeledClause{Asynchronous Task Control}
4415
4416 @begin{Intro}
4417 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4418 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} introduces
4419 a language-defined package to do asynchronous suspend/resume on tasks.
4420 It uses a conceptual @i{held priority} value to represent the task's
4421 @i{held} state.]
4422 @end{Intro}
4423
4424 @begin{StaticSem}
4425
4426 @Leading@;The following language-defined library package exists:
4427 @begin{example}
4428 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]}
4429 @key{with} Ada.Task_Identification;
4430 @key{package} Ada.Asynchronous_Task_Control @key{is}@ChildUnit{parent=[Ada],Child=[Asynchronous_Task_Control]}@Chg{Version=[2],New=[
4431 @key[pragma] Preelaborate(Asynchronous_Task_Control);],Old=[]}
4432 @key{procedure} @AdaSubDefn{Hold}(T : @key[in] Ada.Task_Identification.Task_Id);
4433 @key{procedure} @AdaSubDefn{Continue}(T : @key[in] Ada.Task_Identification.Task_Id);
4434 @key{function} @AdaSubDefn{Is_Held}(T : Ada.Task_Identification.Task_Id)
4435 @key{return} Boolean;
4436 @key{end} Ada.Asynchronous_Task_Control;
4437 @end{example}
4438
4439 @end{StaticSem}
4440
4441 @begin{RunTime}
4442
4443 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]}
4444 @PDefn2{Term=[task state], Sec=(held)}
4445 @Defn{held priority}
4446 @Defn{idle task}
4447 After the Hold operation has been applied to a task, the task becomes
4448 @i{held}. For each processor there is a conceptual @i{idle task},
4449 which is always ready. The base priority of the idle task is below
4450 System.@!Any_@!Priority'First. The @i{held priority} is a
4451 constant of the type @Chg{Version=[2],New=[Integer],Old=[integer]}
4452 whose value is below the base priority of the idle task.
4453 @begin{Discussion}
4454 The held state should not be confused with the blocked state as defined
4455 in @RefSecNum{Task Execution - Task Activation}; the task is still ready.
4456 @end{Discussion}
4457
4458 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00357-01]}
4459 @ChgAdded{Version=[2],Text=[For any priority below System.Any_Priority'First,
4460 the task dispatching policy is FIFO_Within_Priorities.]}
4461 @begin{Honest}
4462 @ChgRef{Version=[2],Kind=[AddedNormal]}
4463 @ChgAdded{Version=[2],Text=[This applies even if a Task_Dispatching_Policy
4464 specifies the policy for all of the priorities of the partition.]}
4465 @end{Honest}
4466 @begin{Ramification}
4467 @ChgRef{Version=[2],Kind=[AddedNormal]}
4468 @ChgAdded{Version=[2],Text=[A task at the held priority never runs, so it is
4469 not necessary to implement FIFO_Within_Priorities for systems that have only
4470 one policy (such as EDF_Across_Priorities).]}
4471 @end{Ramification}
4472
4473 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]}
4474 The Hold operation sets the state of T to held. For a held
4475 task@Chg{Version=[2],New=[, the active
4476 priority is reevaluated as if the base priority of the task were the held
4477 priority],Old=[: the task's own base priority does not constitute an
4478 inheritance source
4479 (see @RefSecNum{Task Priorities}), and the value of the held priority
4480 is defined to be such a source instead]}.
4481 @begin{Ramification}
4482 For example, if T is currently inheriting priorities from other sources (e.g.
4483 it is executing in a protected action), its active priority does not change,
4484 and it continues to execute until it leaves the protected action.
4485 @end{Ramification}
4486
4487 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00357-01]}
4488 The Continue operation resets the state of T to not-held;
4489 @Chg{Version=[2],New=[its],Old=[T's]} active priority
4490 is then reevaluated as @Chg{Version=[2],New=[determined by the
4491 task dispatching policy associated with its base priority.],Old=[described in
4492 @RefSecNum{Task Priorities}.
4493 @Redundant[This time, T's base priority is taken into account.]]}
4494
4495 The Is_Held function returns True if and only if T is in the held state.
4496 @begin{Discussion}
4497 Note that the state of T can be changed immediately after Is_Held returns.
4498 @end{Discussion}
4499
4500 As part of these operations, a check is made that the task
4501 identified by
4502 T is not terminated.
4503 @Defn2{Term=[Tasking_Error],Sec=(raised by failure of run-time check)}
4504 Tasking_Error is raised if the check fails.
4505 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
4506 Program_Error is raised if the value of T is Null_Task_Id.
4507
4508 @end{RunTime}
4509
4510 @begin{Erron}
4511 @PDefn2{Term=(erroneous execution),Sec=(cause)}
4512 If any operation in this package is called with a parameter T that
4513 specifies a task object that no longer exists, the execution of the
4514 program is erroneous.
4515 @end{Erron}
4516
4517 @begin{ImplPerm}
4518
4519 An implementation need not support Asynchronous_Task_Control if it is
4520 infeasible to support it in the target environment.
4521 @begin{Reason}
4522 A direct implementation of the Asynchronous_Task_Control semantics using
4523 priorities is not necessarily efficient enough.
4524 Thus, we envision implementations that use some other mechanism to set
4525 the @lquotes@;held@rquotes@; state.
4526 If there is no other such mechanism,
4527 support for Asynchronous_Task_Control might be infeasible,
4528 because an implementation in terms of priority would require one idle
4529 task per processor.
4530 On some systems, programs are not supposed to know how many processors
4531 are available,
4532 so creating enough idle tasks would be problematic.
4533 @end{Reason}
4534
4535 @end{ImplPerm}
4536
4537 @begin{Notes}
4538
4539 It is a consequence of the priority rules that held tasks cannot be dispatched
4540 on any processor in a partition (unless they are inheriting
4541 priorities) since their priorities are defined to be
4542 below the priority of any idle task.
4543
4544 The effect of calling Get_Priority and Set_Priority on a Held task is the
4545 same as on any other task.
4546
4547 Calling Hold on a held task or Continue on a non-held task has no effect.
4548
4549 @Leading@;The rules affecting queuing are derived from the above rules, in
4550 addition to the normal priority rules:
4551 @begin{itemize}
4552
4553 When a held task is on the ready queue, its priority is so low as to never
4554 reach the top of the queue as long as there are other tasks on that queue.
4555
4556 If a task is executing in a protected action, inside a rendezvous, or is
4557 inheriting priorities from other sources (e.g. when activated), it
4558 continues to execute until it is no longer executing the corresponding
4559 construct.
4560
4561 If a task becomes held while waiting (as a caller) for a rendezvous to
4562 complete, the active priority of the accepting task is not affected.
4563
4564 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0077],ARef=[AI95-00111-01]}
4565 If a task becomes held while waiting in a @nt{selective_accept},
4566 and a@Chg{New=[n],Old=[]} entry call is issued to one of the open entries,
4567 the corresponding @Chg{New=[@nt{accept_@!alternative}],Old=[accept body]}
4568 executes. When the rendezvous completes, the active
4569 priority of the accepting task is lowered to the held priority
4570 (unless it is still inheriting from other sources), and the task does
4571 not execute until another Continue.
4572
4573 The same holds if the held task is the only task on a protected entry queue
4574 whose barrier becomes open. The corresponding entry body executes.
4575
4576 @end{itemize}
4577
4578 @end{Notes}
4579
4580 @begin{Extend95}
4581 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
4582 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
4583 Asynchronous_Task_Control is now Preelaborated,
4584 so it can be used in preelaborated units.]}
4585 @end{Extend95}
4586
4587 @begin{DiffWord95}
4588 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0077],ARef=[AI95-00111-01]}
4589 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected to eliminate the
4590 use of the undefined term @lquotes@;accept body@rquotes@;.]}
4591
4592 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00357-01]}
4593 @ChgAdded{Version=[2],Text=[The description of held tasks was changed to
4594 reflect that the calculation of active priorities depends on the
4595 dispatching policy of the base priority. Thus, the policy of the held
4596 priority was specified in order to avoid surprises (especially when using
4597 the EDF policy).]}
4598 @end{DiffWord95}
4599
4600
4601 @LabeledClause{Other Optimizations and Determinism Rules}
4602
4603 @begin{Intro}
4604 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4605 @Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} describes
4606 various requirements for
4607 improving the response and determinism in a real-time system.]
4608 @end{Intro}
4609
4610 @begin{ImplReq}
4611
4612 If the implementation blocks interrupts (see @RefSecNum{Interrupt Support}) not
4613 as a result of direct user
4614 action (e.g. an execution of a protected action) there shall be an upper
4615 bound on the duration of this blocking.
4616 @begin{Ramification}
4617 The implementation shall not allow itself to be interrupted when it is in a
4618 state where it is unable to support all the language-defined operations
4619 permitted in the execution of interrupt handlers.
4620 (see @RefSecNum{Protected Subprograms and Protected Actions}).
4621 @end{Ramification}
4622
4623 The implementation shall recognize entry-less protected types.
4624 The overhead of acquiring the execution resource of an object of such a type
4625 (see @RefSecNum{Protected Subprograms and Protected Actions}) shall be
4626 minimized. In particular, there should not be any overhead due to evaluating
4627 @nt{entry_barrier} @nt{condition}s.
4628 @begin{ImplNote}
4629 Ideally the overhead should just be a spin-lock.
4630 @end{ImplNote}
4631
4632 Unchecked_Deallocation shall be supported for terminated tasks that are
4633 designated by access types, and shall have the effect of releasing all
4634 the storage associated with the task. This includes any run-time system
4635 or heap storage that has been implicitly allocated for the task by the
4636 implementation.
4637
4638 @end{ImplReq}
4639
4640 @begin{DocReq}
4641
4642 The implementation shall document the
4643 upper bound on the duration of interrupt blocking caused by the
4644 implementation. If this is different for different interrupts or
4645 interrupt priority levels, it should be documented for each case.
4646 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
4647 Text=[@ChgDeleted{Version=[2],
4648 Text=[The upper bound on the duration of interrupt blocking caused by
4649 the implementation.]}]}
4650 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4651 Text=[The upper bound on the duration of interrupt blocking caused by
4652 the implementation.]}]}
4653
4654 @end{DocReq}
4655
4656 @begin{Metrics}
4657 @Leading@;The implementation shall document the following metric:
4658 @begin{Itemize}
4659 The overhead associated with obtaining
4660 a mutual-exclusive access to an entry-less protected object. This shall be
4661 measured in the following way:
4662
4663 @NoPrefix@Leading@keepnext@;For a protected object of the form:
4664 @begin{example}
4665 @key{protected} Lock @key{is}
4666 @key{procedure} Set;
4667 @Key{function} Read @Key{return} Boolean;
4668 @key{private}
4669 Flag : Boolean := False;
4670 @key{end} Lock;
4671
4672 @key{protected body} Lock @key{is}
4673 @key{procedure} Set @key{is}
4674 @key{begin}
4675 Flag := True;
4676 @key{end} Set;
4677 @Key{function} Read @Key{return} Boolean
4678 @key{Begin}
4679 @key{return} Flag;
4680 @key{end} Read;
4681 @key{end} Lock;
4682 @end{example}
4683
4684 @NoPrefix@;The execution time, in processor clock cycles, of a call to
4685 Set. This shall be measured between the point just before
4686 issuing the call, and the point just after the call
4687 completes.
4688 The function Read shall be called later to verify that Set was indeed
4689 called (and not optimized away). The
4690 calling task shall have
4691 sufficiently high priority as to not be preempted during the measurement
4692 period. The protected object shall have sufficiently high ceiling priority
4693 to allow the task to call Set.
4694
4695 @NoPrefix@;For a multiprocessor, if supported, the metric shall be reported for the
4696 case where no contention (on the execution resource) exists
4697 @Redundant[from tasks executing on other processors].
4698 @end{Itemize}
4699 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4700 Text=[The metrics for entry-less protected objects.]}]}
4701 @end{Metrics}
4702
4703
4704 @LabeledRevisedClause{Version=[3],InitialVersion=[2],New=[The Ravenscar Profile],Old=[Run-time Profiles]}
4705
4706 @begin{Intro}
4707 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4708 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0246-1],ARef=[AI05-0299-1]}
4709 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
4710 @Chg{Version=[3],New=[defines the Ravenscar profile.@Defn{Ravenscar}],
4711 Old=[specifies a mechanism for defining run-time profiles.]}]]}
4712 @end{Intro}
4713
4714 @begin{NotIso}
4715 @ChgAdded{Version=[3],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 2
4716 and 3 were moved to @RefSec{Pragma Restrictions and Pragma Profile}.>}]}@Comment{This message
4717 should be deleted if the paragraphs are ever renumbered.}
4718 @end{NotIso}
4719
4720 @begin{Syntax}
4721 @begin{SyntaxText}
4722 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4723 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0246-1]}
4724 @ChgDeleted{Version=[3],Type=[Leading],Keepnext=[T],Text=[@Chg{Version=[2],New=[The
4725 form of a @nt{pragma} Profile is as follows:],Old=[]}]}
4726 @end{SyntaxText}
4727
4728 @ChgRef{Version=[2],Kind=[AddedNormal]}
4729 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
4730 @DeletedPragmaSyn<Version=[3],InitialVersion=[2],@ChgDeleted{Version=[3],
4731 Text=`@Chg[Version=[2],New=[@key{pragma} @prag<Profile> (@SynI{profile_}@Syn2{identifier} {, @SynI{profile_}@Syn2{pragma_argument_association}});],Old=[]]'}>
4732
4733 @end{Syntax}
4734
4735 @begin{Legality}
4736 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4737 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0246-1]}
4738 @ChgAdded{Version=[2],Text=[The @SynI{profile_}@nt{identifier}
4739 @Chg{Version=[3],New=[Ravenscar is a usage profile (see @RefSecNum{Pragma Restrictions and Pragma Profile}).
4740 For usage profile Ravenscar, there shall be no],Old=[shall be the name
4741 of a run-time profile. The semantics of any]}
4742 @SynI{profile_}@nt{pragma_@!argument_@!association}s@Chg{Version=[3],New=[],Old=[
4743 are defined by
4744 the run-time profile specified by the @SynI{profile_}@nt{identifier}]}.]}
4745 @end{Legality}
4746
4747 @begin{StaticSem}
4748 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4749 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0246-1]}
4750 @ChgAdded{Version=[2],Type=[Leading],Text=[@Chg{Version=[3],New=[The
4751 usage profile Ravenscar is equivalent to the following set of
4752 pragmas:],Old=[A profile is equivalent to the set of configuration
4753 pragmas that is defined for each run-time profile.]}]}
4754
4755 @begin{Example}
4756 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI95-00249-01],ARef=[AI95-00297-01],ARef=[AI95-00394-01],ARef=[AI05-0171-1],ARef=[AI05-0246-1]}
4757 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0055-1],ARef=[AI12-0073-1]}
4758 @ChgAdded{Version=[3],Text=[
4759 @key{pragma} Task_Dispatching_Policy (FIFO_Within_Priorities);
4760 @key{pragma} Locking_Policy (Ceiling_Locking);
4761 @key{pragma} Detect_Blocking;
4762 @key{pragma} Restrictions (
4763 No_Abort_Statements,
4764 No_Dynamic_Attachment@Chg{Version=[4],New=[,
4765 No_Dynamic_CPU_Assignment],Old=[]},
4766 No_Dynamic_Priorities,
4767 No_Implicit_Heap_Allocations,
4768 No_Local_Protected_Objects,
4769 No_Local_Timing_Events,
4770 No_Protected_Type_Allocators,
4771 No_Relative_Delay,
4772 No_Requeue_Statements,
4773 No_Select_Statements,
4774 No_Specific_Termination_Handlers,
4775 No_Task_Allocators,
4776 No_Task_Hierarchy,
4777 No_Task_Termination,
4778 Simple_Barriers,
4779 Max_Entry_Queue_Length => 1,
4780 Max_Protected_Entries => 1,
4781 Max_Task_Entries => 0,
4782 No_Dependence => Ada.Asynchronous_Task_Control,
4783 No_Dependence => Ada.Calendar,
4784 No_Dependence => Ada.Execution_Time.Group_Budgets,
4785 No_Dependence => Ada.Execution_Time.Timers@Chg{Version=[4],New=[,
4786 No_Dependence => Ada.Synchronous_Barriers,],Old=[]}
4787 No_Dependence => Ada.Task_Attributes@Chg{Version=[3],New=[,
4788 No_Dependence => System.Multiprocessors.Dispatching_Domains],Old=[]});]}
4789 @end{Example}
4790
4791 @begin{Discussion}
4792 @ChgRef{Version=[3],Kind=[AddedNormal]}
4793 @ChgAdded{Version=[3],Text=[The Ravenscar profile is named for the location
4794 of the meeting that defined its initial version. The name is now in widespread
4795 use, so we stick with existing practice, rather than using a more descriptive
4796 name.@Comment{ This is another example of Ada's lousy marketing sense; casual
4797 readers, especially those outside of Ada, have no conception of what
4798 @lquotes@;Ravenscar@rquotes@; is, and thus are much less likely to investigate
4799 it to find out how it can help them.}]}
4800 @end{Discussion}
4801 @end{StaticSem}
4802
4803 @begin{Linktime}
4804 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4805 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0246-1]}
4806 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[@PDefn2{Term=[configuration pragma], Sec=(Profile)}
4807 @PDefn2{Term=[pragma, configuration], Sec=(Profile)}
4808 A @nt{pragma} Profile is a configuration pragma.
4809 There may be more than one @nt{pragma} Profile for a partition.]}]}
4810 @end{Linktime}
4811 @begin{NotIso}
4812 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraph 7 was
4813 deleted.>}]}@Comment{This message should be deleted if the paragraphs
4814 are ever renumbered.}
4815 @end{NotIso}
4816
4817 @begin{ImplReq}
4818 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
4819 @ChgRef{Version=[4],Kind=[Deleted],ARef=[AI12-0055-1]}
4820 @ChgAdded{Version=[3],Text=[@Chg{Version=[4],New=[],Old=[A task shall only be
4821 on the ready queues of one processor, and the
4822 processor to which a task belongs shall be defined statically.
4823 Whenever a task running on a processor reaches a task dispatching point,
4824 it goes back to the ready queues of the same processor. A task with
4825 a CPU value of Not_A_Specific_CPU will execute on an implementation
4826 defined processor. @Redundant[A task without a CPU aspect will activate and
4827 execute on the same processor as its activating task.]]}]}
4828 @begin{TheProof}
4829 @ChgRef{Version=[3],Kind=[AddedNormal]}
4830 @ChgRef{Version=[4],Kind=[DeletedNoDelMsg]}
4831 @ChgAdded{Version=[3],Text=[@Chg{Version=[4],New=[],Old=[The processor of a
4832 task without a CPU aspect is defined in @RefSecNum{Multiprocessor Implementation}.]}]}
4833 @end{TheProof}
4834 @Comment{@ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
4835 Text=[The processor on which a task with a CPU value of a Not_A_Specific_CPU
4836 will execute when the Ravenscar profile is in effect.]}]}}
4837 @end{ImplReq}
4838
4839 @begin{ImplAdvice}
4840 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
4841 @ChgAdded{Version=[3],Text=[On a multiprocessor system, an implementation should
4842 support a fully partitioned approach. Each processor should have separate and
4843 disjoint ready queues.]}
4844
4845 @ChgImplAdvice{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
4846 Text=[On a multiprocessor system, each processor should have a separate
4847 and disjoint ready queue.]}]}
4848 @end{ImplAdvice}
4849
4850 @begin{Notes}
4851 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI95-00249-01],ARef=[AI05-0246-1]}
4852 @ChgAdded{Version=[3],Text=[The effect of the Max_Entry_Queue_Length => 1
4853 restriction applies only to protected entry queues due to the accompanying
4854 restriction of Max_Task_Entries => 0.]}
4855
4856 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0055-1]}
4857 @ChgAdded{Version=[4],Text=[When the Ravenscar profile is in effect (via the
4858 effect of the No_Dynamic_CPU_Assignment restriction), all of the tasks in the
4859 partition will execute on a single CPU unless the programmer explicitly uses
4860 aspect CPU to specify the CPU assignments for tasks. The use of multiple CPUs
4861 requires care, as many guarantees of single CPU scheduling no longer apply.]}
4862
4863 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0055-1]}
4864 @ChgAdded{Version=[4],Text=[It is not recommended to specify the CPU of a task
4865 to be Not_A_Specific_CPU when the Ravenscar profile is in effect. How a
4866 partition executes strongly depends on the assignment of tasks to CPUs.]}
4867 @end{Notes}
4868
4869 @begin{Extend95}
4870 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4871 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0246-1]}
4872 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
4873 @Chg{Version=[3],New=[The Ravenscar profile is new; it was moved here by Ada
4874 2012],Old=[@nt{Pragma} Profile is new]}.]}
4875 @end{Extend95}
4876
4877 @begin{DiffWord2005}
4878 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
4879 @ChgAdded{Version=[3],Text=[How Ravenscar behaves on a multiprocessor
4880 system is now defined.]}
4881 @end{DiffWord2005}
4882
4883 @begin{Incompatible2012}
4884 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0073-1]}
4885 @ChgAdded{Version=[4],Text=[@Defn{incompatibilities with Ada 2012}@b<Corrigendum:>
4886 The Ravenscar profile no longer allows the use of package Synchronous_Barriers,
4887 as this package violates the fundamental Ravenscar requirement that each
4888 waiting point can only block (and release) a single task. This is incompatible
4889 with the published Ada 2012 standard, but it is unlikely that any existing
4890 Ravenscar runtime ever usefully supported barriers.]}
4891
4892 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0055-1]}
4893 @ChgAdded{Version=[4],Text=[@b<Corrigendum:>The Ravenscar profile (via the
4894 effect of the new restriction No_Dynamic_CPU_Assignment) no longer allows
4895 setting the CPU aspect of a task to a non-static value. While this was
4896 allowed, an implementation would have had to come up with a creative
4897 interpretation of the Ada 2012 requirement to define the association of
4898 tasks to processors statically. As such, the new check is more likely to
4899 catch bugs than break a working program.]}
4900 @end{Incompatible2012}
4901
4902
4903 @Comment{Moved the following to the previous subclause...
4904 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
4905 @LabeledAddedSubClause{Version=[2],Name=[The Ravenscar Profile]}
4906
4907 @begin{Intro}
4908 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4909 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
4910 @ChgAdded{Version=[2],Text=[@Redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]}
4911 defines the Ravenscar profile.]@Defn{Ravenscar}]}
4912 @end{Intro}
4913
4914 @begin{Legality}
4915 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4916 @ChgAdded{Version=[2],Text=[The @SynI{profile_}@nt{identifier}
4917 Ravenscar is a run-time profile.
4918 For run-time profile Ravenscar, there shall be no
4919 @Syni{profile_}@nt{pragma_argument_association}s.]}
4920 @end{Legality}
4921
4922 @begin{StaticSem}
4923 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
4924 @ChgAdded{Version=[2],Type=[Leading],Text=[The run-time profile
4925 Ravenscar is equivalent to the following set of pragmas:]}
4926
4927 @begin{Example}
4928 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01],ARef=[AI95-00297-01],ARef=[AI95-00394-01]}
4929 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0171-1]}
4930 @ChgAdded{Version=[2],Text=[
4931 @key{pragma} Task_Dispatching_Policy (FIFO_Within_Priorities);
4932 @key{pragma} Locking_Policy (Ceiling_Locking);
4933 @key{pragma} Detect_Blocking;
4934 @key{pragma} Restrictions (
4935 No_Abort_Statements,
4936 No_Dynamic_Attachment,
4937 No_Dynamic_Priorities,
4938 No_Implicit_Heap_Allocations,
4939 No_Local_Protected_Objects,
4940 No_Local_Timing_Events,
4941 No_Protected_Type_Allocators,
4942 No_Relative_Delay,
4943 No_Requeue_Statements,
4944 No_Select_Statements,
4945 No_Specific_Termination_Handlers,
4946 No_Task_Allocators,
4947 No_Task_Hierarchy,
4948 No_Task_Termination,
4949 Simple_Barriers,
4950 Max_Entry_Queue_Length => 1,
4951 Max_Protected_Entries => 1,
4952 Max_Task_Entries => 0,
4953 No_Dependence => Ada.Asynchronous_Task_Control,
4954 No_Dependence => Ada.Calendar,
4955 No_Dependence => Ada.Execution_Time.Group_Budgets,
4956 No_Dependence => Ada.Execution_Time.Timers,
4957 No_Dependence => Ada.Task_Attributes@Chg{Version=[3],New=[,
4958 No_Dependence => System.Multiprocessors.Dispatching_Domains],Old=[]});]}
4959 @end{Example}
4960
4961 @begin{Discussion}
4962 @ChgRef{Version=[2],Kind=[AddedNormal]}
4963 @ChgAdded{Version=[2],Text=[The Ravenscar profile is named for the location
4964 of the meeting that defined its initial version. The name is now in widespread
4965 use, so we stick with existing practice, rather than using a more descriptive
4966 name.@Comment{ This is another example of Ada's lousy marketing sense; casual
4967 readers, especially those outside of Ada, have no conception of what
4968 @lquotes@;Ravenscar@rquotes@; is, and thus are much less likely to investigate
4969 it to find out how it can help them.}]}
4970 @end{Discussion}
4971
4972 @end{StaticSem}
4973
4974 @begin{ImplReq}
4975 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
4976 @ChgAdded{Version=[3],Text=[A task shall only be on the ready queues of one
4977 processor, and the
4978 processor to which a task belongs shall be defined statically.
4979 Whenever a task running on a processor reaches a task dispatching point,
4980 it goes back to the ready queues of the same processor. A task with
4981 a CPU value of Not_A_Specific_CPU will execute on an implementation
4982 defined processor. @Redundant[A task without a CPU aspect will activate and
4983 execute on the same processor as its activating task.]]}
4984 @begin{TheProof}
4985 @ChgRef{Version=[3],Kind=[AddedNormal]}
4986 @ChgAdded{Version=[3],Text=[The processor of a task without an aspect CPU is
4987 defined in @RefSecNum{Multiprocessor Implementation}.]}
4988 @end{TheProof}
4989 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
4990 Text=[The processor on which a task with a CPU value of a Not_A_Specific_CPU
4991 will execute when the Ravenscar profile is in effect.]}]}
4992 @end{ImplReq}
4993
4994 @begin{ImplAdvice}
4995 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
4996 @ChgAdded{Version=[3],Text=[On a multiprocessor system, an implementation should
4997 support a fully partitioned approach. Each processor should have separate and
4998 disjoint ready queues.]}
4999
5000 @ChgImplAdvice{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
5001 Text=[On a multiprocessor system, each processor should have a separate
5002 and disjoint ready queue.]}]}
5003 @end{ImplAdvice}
5004
5005 @begin{Notes}
5006 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
5007 @ChgAdded{Version=[2],Text=[
5008 The effect of the Max_Entry_Queue_Length => 1 restriction applies
5009 only to protected entry queues due to the accompanying restriction of
5010 Max_Task_Entries => 0.]}
5011 @end{Notes}
5012
5013 @begin{Extend95}
5014 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00249-01]}
5015 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
5016 The Ravenscar profile is new.]}
5017 @end{Extend95}
5018
5019 @begin{DiffWord2005}
5020 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
5021 @ChgAdded{Version=[3],Text=[How Ravenscar behaves on a multiprocessor
5022 system is now defined.]}
5023 @end{DiffWord2005}
5024 end commented out text...}@Comment{End of original Ravenscar}
5025
5026
5027 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
5028 @LabeledAddedClause{Version=[2],Name=[Execution Time]}
5029
5030 @begin{Intro}
5031 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5032 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
5033 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
5034 describes a language-defined package to measure execution time.]}
5035 @end{Intro}
5036
5037 @begin{StaticSem}
5038 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5039 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
5040 language-defined library package exists:]}
5041 @begin{Example}
5042 @ChgRef{Version=[2],Kind=[AddedNormal]}
5043 @ChgAdded{Version=[2],Text=[@key{with} Ada.Task_Identification;
5044 @key{with} Ada.Real_Time; @key{use} Ada.Real_Time;
5045 @key{package} Ada.Execution_Time @key{is}@ChildUnit{Parent=[Ada],Child=[Execution_Time]}]}
5046
5047 @ChgRef{Version=[2],Kind=[AddedNormal]}
5048 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{CPU_Time} @key{is private};
5049 @AdaObjDefn{CPU_Time_First} : @key{constant} CPU_Time;
5050 @AdaObjDefn{CPU_Time_Last} : @key{constant} CPU_Time;
5051 @AdaObjDefn{CPU_Time_Unit} : @key{constant} := @RI{implementation-defined-real-number};
5052 @AdaObjDefn{CPU_Tick} : @key{constant} Time_Span;]}
5053
5054 @ChgRef{Version=[2],Kind=[AddedNormal]}
5055 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Clock}
5056 (T : Ada.Task_Identification.Task_Id
5057 := Ada.Task_Identification.Current_Task)
5058 @key{return} CPU_Time;]}
5059
5060 @ChgRef{Version=[2],Kind=[AddedNormal]}
5061 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left : CPU_Time; Right : Time_Span) @key{return} CPU_Time;
5062 @key{function} "+" (Left : Time_Span; Right : CPU_Time) @key{return} CPU_Time;
5063 @key{function} "-" (Left : CPU_Time; Right : Time_Span) @key{return} CPU_Time;
5064 @key{function} "-" (Left : CPU_Time; Right : CPU_Time) @key{return} Time_Span;]}
5065
5066 @ChgRef{Version=[2],Kind=[AddedNormal]}
5067 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : CPU_Time) @key{return} Boolean;
5068 @key{function} "<=" (Left, Right : CPU_Time) @key{return} Boolean;
5069 @key{function} ">" (Left, Right : CPU_Time) @key{return} Boolean;
5070 @key{function} ">=" (Left, Right : CPU_Time) @key{return} Boolean;]}
5071
5072 @ChgRef{Version=[2],Kind=[AddedNormal]}
5073 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Split}
5074 (T : @key{in} CPU_Time; SC : @key{out} Seconds_Count; TS : @key{out} Time_Span);]}
5075
5076 @ChgRef{Version=[2],Kind=[AddedNormal]}
5077 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Of} (SC : Seconds_Count;
5078 TS : Time_Span := Time_Span_Zero) @key{return} CPU_Time;]}
5079
5080 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0170-1]}
5081 @ChgAdded{Version=[3],Text=[ @AdaObjDefn{Interrupt_Clocks_Supported} : @key[constant] Boolean := @RI<implementation-defined>;]}
5082
5083 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0170-1]}
5084 @ChgAdded{Version=[3],Text=[ @AdaObjDefn{Separate_Interrupt_Clocks_Supported} : @key[constant] Boolean :=
5085 @RI<implementation-defined>;]}
5086
5087 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0170-1]}
5088 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Clock_For_Interrupts} @key[return] CPU_Time;]}
5089
5090 @ChgRef{Version=[2],Kind=[AddedNormal]}
5091 @ChgAdded{Version=[2],Text=[@key{private}
5092 ... -- @RI[not specified by the language]
5093 @key{end} Ada.Execution_Time;]}
5094
5095 @end{Example}
5096
5097 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5098 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0170-1],ARef=[AI05-0269-1]}
5099 @ChgAdded{Version=[2],Text=[@Defn2{Term=[execution time],Sec=[of a task]}
5100 @Defn2{Term=[CPU time],Sec=[of a task]}
5101 The @i<execution time> or CPU time of a given task is defined as the time spent by
5102 the system executing that task, including the time spent executing run-time or
5103 system services on its behalf. The mechanism used to measure execution time is
5104 implementation defined. @Chg{Version=[3],New=[The Boolean constant Interrupt_Clocks_Supported is
5105 set to True if the implementation separately accounts for the execution time
5106 of interrupt handlers. If it is set to False it],Old=[It]} is implementation
5107 defined which task, if any, is charged the execution time that is consumed by
5108 interrupt handlers@Chg{Version=[3],New=[. The Boolean constant
5109 Separate_Interrupt_Clocks_Supported is set to True if the implementation
5110 separately accounts for the execution time of individual interrupt
5111 handlers (see @RefSecNum{Execution Time of Interrupt Handlers})],Old=[ and
5112 run-time services on behalf of the system]}.]}
5113 @begin{Discussion}
5114 @ChgRef{Version=[2],Kind=[AddedNormal]}
5115 @ChgAdded{Version=[2],Text=[The implementation-defined properties above
5116 and of the values declared in the package are repeated in @DocReqTitle,
5117 so we don't mark them as implementation-defined.]}
5118 @end{Discussion}
5119
5120 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5121 @ChgAdded{Version=[2],Text=[The type CPU_Time represents the execution time of
5122 a task. The set of values of this type corresponds one-to-one with an
5123 implementation-defined range of mathematical integers.]}
5124
5125 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5126 @ChgAdded{Version=[2],Text=[The CPU_Time value I represents the half-open
5127 execution-time interval that starts with I*CPU_Time_Unit and is limited by
5128 (I+1)*CPU_Time_Unit, where CPU_Time_Unit is an implementation-defined
5129 real number. For each task, the execution time value is set to zero at
5130 the creation of the task.]}
5131
5132 @begin{Ramification}
5133 @ChgRef{Version=[2],Kind=[AddedNormal]}
5134 @ChgAdded{Version=[2],Text=[Since it is implementation-defined which task
5135 is charged execution time for system services, the execution time value
5136 may become nonzero even before the start of the activation of the task.]}
5137 @end{Ramification}
5138
5139 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5140 @ChgAdded{Version=[2],Text=[CPU_Time_First and CPU_Time_Last are the smallest
5141 and largest values of the CPU_Time type, respectively.]}
5142 @end{StaticSem}
5143
5144 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0170-1]}
5145 @ChgAdded{Version=[3],Text=[The execution time value for the
5146 function Clock_For_Interrupts is initialized to zero.]}
5147
5148 @begin{RunTime}
5149
5150 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5151 @ChgAdded{Version=[2],Text=[@Defn{CPU clock tick}
5152 CPU_Time_Unit is the smallest amount of execution time representable
5153 by the CPU_Time type; it is expressed in seconds. A @i<CPU clock tick> is an
5154 execution time interval during which the clock value (as observed by
5155 calling the Clock function) remains constant. CPU_Tick is the average
5156 length of such intervals.]}
5157
5158 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5159 @ChgAdded{Version=[2],Text=[The effects of the operators on CPU_Time and
5160 Time_Span are as for the operators defined for integer types.]}
5161
5162 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5163 @ChgAdded{Version=[2],Text=[The function Clock returns the current execution
5164 time of the task identified by T; Tasking_Error is raised if that task has
5165 terminated; Program_Error is raised if the value of T is
5166 Task_Identification.Null_Task_Id.]}
5167
5168 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5169 @ChgAdded{Version=[2],Text=[The effects of the Split and Time_Of operations are defined as
5170 follows, treating values of type CPU_Time, Time_Span, and
5171 Seconds_Count as mathematical integers. The effect of Split (T, SC,
5172 TS) is to set SC and TS to values such that T*CPU_Time_Unit = SC*1.0 +
5173 TS*CPU_Time_Unit, and 0.0 <= TS*CPU_Time_Unit < 1.0. The value
5174 returned by Time_Of(SC,TS) is the execution-time value T such that
5175 T*CPU_Time_Unit=SC*1.0 + TS*CPU_Time_Unit.]}
5176
5177 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0170-1]}
5178 @ChgAdded{Version=[3],Text=[The function Clock_For_Interrupts returns the total
5179 cumulative time spent executing within all interrupt handlers. This time is not
5180 allocated to any task execution time clock. If Interrupt_Clocks_Supported is set
5181 to False the function raises Program_Error.]}
5182
5183 @end{RunTime}
5184
5185 @begin{Erron}
5186 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5187 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)}
5188 For a call of Clock, if the task identified by T no longer exists, the
5189 execution of the program is erroneous.]}
5190 @end{Erron}
5191
5192 @begin{ImplReq}
5193 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5194 @ChgAdded{Version=[2],Text=[The range of CPU_Time values shall be sufficient
5195 to uniquely represent the range of execution times from the task start-up to 50
5196 years of execution time later. CPU_Tick shall be no greater than 1
5197 millisecond.]}
5198 @end{ImplReq}
5199
5200 @begin{DocReq}
5201
5202 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5203 @ChgAdded{Version=[2],Text=[The implementation shall document the values of
5204 CPU_Time_First, CPU_Time_Last, CPU_Time_Unit, and CPU_Tick.]}
5205 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
5206 Text=[The values of CPU_Time_First, CPU_Time_Last, CPU_Time_Unit, and CPU_Tick
5207 of package Execution_Time.]}]}
5208
5209 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5210 @ChgAdded{Version=[2],Text=[The implementation shall document the properties of
5211 the underlying mechanism used to measure execution times, such as the range of
5212 values supported and any relevant aspects of the underlying hardware or
5213 operating system facilities used.]}
5214 @ChgDocReq{Version=[3],Kind=[Revised],InitialVersion=[2],
5215 Text=[@ChgAdded{Version=[2],
5216 Text=[The properties of the mechanism used to implement
5217 package Execution_Time@Chg{Version=[3],New=[,
5218 including the values of the constants defined in the package],Old=[]}.]}]}
5219
5220 @end{DocReq}
5221
5222 @begin{Metrics}
5223
5224 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5225 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The implementation
5226 shall document the following metrics:]}
5227
5228 @begin{Itemize}
5229 @ChgRef{Version=[2],Kind=[AddedNormal]}
5230 @ChgAdded{Version=[2],Text={An upper bound on the execution-time duration of a
5231 clock tick. This is a value D such that if t1 and t2 are any execution times of
5232 a given task such that t1 < t2 and Clock@-{t1} = Clock@-{t2} then
5233 t2 @en@; t1 <= D.}}
5234
5235 @ChgRef{Version=[2],Kind=[AddedNormal]}
5236 @ChgAdded{Version=[2],Text=[An upper bound on the size of a clock jump. A clock
5237 jump is the difference between two successive distinct values of an
5238 execution-time clock (as observed by calling the Clock function with the same
5239 Task_Id).]}
5240
5241 @ChgRef{Version=[2],Kind=[AddedNormal]}
5242 @ChgAdded{Version=[2],Text=[An upper bound on the execution time of a call to
5243 the Clock function, in processor clock cycles.]}
5244
5245 @ChgRef{Version=[2],Kind=[AddedNormal]}
5246 @ChgAdded{Version=[2],Text=[Upper bounds on the execution times of the
5247 operators of the type CPU_Time, in processor clock cycles.]}
5248 @end{Itemize}
5249 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
5250 Text=[The metrics for execution time.]}]}
5251
5252 @end{Metrics}
5253
5254 @begin{ImplPerm}
5255
5256 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5257 @ChgAdded{Version=[2],Text=[Implementations targeted to machines with word size
5258 smaller than 32 bits need not support the full range and granularity of the
5259 CPU_Time type.]}
5260
5261 @end{ImplPerm}
5262
5263 @begin{ImplAdvice}
5264
5265 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5266 @ChgAdded{Version=[2],Text=[When appropriate, implementations should provide
5267 configuration mechanisms to change the value of CPU_Tick.]}
5268 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
5269 Text=[When appropriate, implementations should provide
5270 configuration mechanisms to change the value of Execution_Time.CPU_Tick.]}]}
5271
5272 @end{ImplAdvice}
5273
5274 @begin{Extend95}
5275 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5276 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
5277 The package Execution_Time is new.]}
5278 @end{Extend95}
5279
5280 @begin{Incompatible2005}
5281 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5282 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}
5283 Function Clock_For_Interrupts, and constants Interrupt_Clocks_Supported and
5284 Separate_Interrupt_Clocks_Supported are added to Execution_Time.
5285 If Execution_Time is referenced in a @nt{use_clause}, and an
5286 entity @i<E> with a @nt{defining_identifier} of one of the added entities
5287 is defined in a package that is also referenced in a @nt{use_clause}, the entity
5288 @i<E> may no longer be use-visible, resulting in errors. This should be rare
5289 and is easily fixed if it does occur.]}
5290 @end{Incompatible2005}
5291
5292 @begin{Diffword2005}
5293 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5294 @ChgAdded{Version=[3],Text=[If Interrupt_Clocks_Supported is True, it is
5295 now possible to determine the execution time of interrupt handlers. This
5296 is not an inconsistency, as not charging any task for such time was a
5297 legitimate implementation for Ada 2005.]}
5298 @end{Diffword2005}
5299
5300
5301 @LabeledAddedSubclause{Version=[2],Name=[Execution Time Timers]}
5302
5303 @begin{Intro}
5304 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5305 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
5306 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
5307 describes a language-defined package
5308 that provides a facility for calling a handler when a task has used a defined
5309 amount of CPU time.]}
5310 @end{Intro}
5311
5312 @begin{StaticSem}
5313 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5314 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
5315 language-defined library package exists:]}
5316 @begin{Example}
5317 @ChgRef{Version=[2],Kind=[AddedNormal]}
5318 @ChgAdded{Version=[2],Text=[@key{with} System;
5319 @key{package} Ada.Execution_Time.Timers @key{is}@ChildUnit{Parent=[Ada.Execution_Time],Child=[Timers]}]}
5320
5321 @ChgRef{Version=[2],Kind=[AddedNormal]}
5322 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timer} (T : @key{not null access constant}
5323 Ada.Task_Identification.Task_Id) @key{is}
5324 @key{tagged limited private};]}
5325
5326 @ChgRef{Version=[2],Kind=[AddedNormal]}
5327 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timer_Handler} @key{is}
5328 @key{access protected procedure} (TM : @key{in out} Timer);]}
5329
5330 @ChgRef{Version=[2],Kind=[AddedNormal]}
5331 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Min_Handler_Ceiling} : @key{constant} System.Any_Priority :=
5332 @RI[implementation-defined];]}
5333
5334 @ChgRef{Version=[2],Kind=[AddedNormal]}
5335 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (TM : @key{in out} Timer;
5336 In_Time : @key{in} Time_Span;
5337 Handler : @key{in} Timer_Handler);
5338 @key{procedure} @AdaSubDefn{Set_Handler} (TM : @key{in out} Timer;
5339 At_Time : @key{in} CPU_Time;
5340 Handler : @key{in} Timer_Handler);
5341 @key{function} @AdaSubDefn{Current_Handler} (TM : Timer) @key{return} Timer_Handler;
5342 @key{procedure} @AdaSubDefn{Cancel_Handler} (TM : @key{in out} Timer;
5343 Cancelled : @key{out} Boolean);]}
5344
5345 @ChgRef{Version=[2],Kind=[AddedNormal]}
5346 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Remaining} (TM : Timer) @key{return} Time_Span;]}
5347
5348 @ChgRef{Version=[2],Kind=[AddedNormal]}
5349 @ChgAdded{Version=[2],Text=[ @AdaExcDefn{Timer_Resource_Error} : @key{exception};]}
5350
5351 @ChgRef{Version=[2],Kind=[AddedNormal]}
5352 @ChgAdded{Version=[2],Text=[@key{private}
5353 ... -- @RI{not specified by the language}
5354 @key{end} Ada.Execution_Time.Timers;]}
5355
5356 @end{Example}
5357
5358 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5359 @ChgAdded{Version=[2],Text=[The type Timer represents an execution-time event
5360 for a single task and is capable of detecting execution-time overruns. The
5361 access discriminant T identifies the task concerned. The type Timer needs
5362 finalization (see @RefSecNum{Assignment and Finalization}).]}
5363
5364 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5365 @ChgAdded{Version=[2],Text=[An object of type Timer is said to be @i<set> if it
5366 is associated with a nonnull value of type Timer_Handler and @i<cleared>
5367 otherwise. All Timer objects are initially cleared.
5368 @PDefn2{Term=[set],Sec=[execution timer object]}
5369 @PDefn2{Term=[clear],Sec=[execution timer object]}]}
5370
5371 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5372 @ChgAdded{Version=[2],Text=[The type Timer_Handler identifies a protected
5373 procedure to be executed by the implementation when the timer expires. Such a
5374 protected procedure is called a @i<handler>.
5375 @PDefn2{Term=[handler],Sec=[execution timer]}]}
5376
5377 @begin{Discussion}
5378 @ChgRef{Version=[2],Kind=[AddedNormal]}
5379 @ChgAdded{Version=[2],Text=[Type Timer is tagged. This makes it possible to
5380 share a handler between several events. In simple cases, 'Access can be used
5381 to compare the parameter with a specific timer object (this works because a
5382 tagged type is a by-reference type). In more complex cases, a type extension
5383 of type Timer can be declared; a double type conversion can be used to access
5384 the extension data. An example of how this can be done can be found for the
5385 similar type Timing_Event, see @RefSecNum{Timing Events}.]}
5386 @end{Discussion}
5387
5388 @end{StaticSem}
5389
5390 @begin{Runtime}
5391
5392 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5393 @ChgAdded{Version=[2],Text=[When a Timer object is created, or upon the first
5394 call of a Set_Handler procedure with the timer as parameter, the resources
5395 required to operate an execution-time timer based on the associated
5396 execution-time clock are allocated and initialized. If this operation would
5397 exceed the available resources, Timer_Resource_Error is raised.]}
5398
5399 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5400 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5401 @ChgAdded{Version=[2],Text=[The procedures Set_Handler associate the handler
5402 Handler with the timer TM@Chg{Version=[3],New=[:],Old=[;]}
5403 if Handler is @key[null], the timer is cleared@Chg{Version=[3],New=[;],Old=[,]}
5404 otherwise@Chg{Version=[3],New=[,],Old=[]} it is set. The first procedure
5405 Set_Handler loads the timer TM with an interval specified by the Time_Span
5406 parameter. In this mode, the timer TM @i<expires> when the execution time of the
5407 task identified by TM.T.@key[all] has increased by In_Time; if In_Time is less
5408 than or equal to zero, the timer expires immediately. The second procedure
5409 Set_Handler loads the timer TM with the absolute value specified by At_Time. In
5410 this mode, the timer TM expires when the execution time of the task identified
5411 by TM.T.@key[all] reaches At_Time; if the value of At_Time has already been
5412 reached when Set_Handler is called, the timer expires
5413 immediately.@Defn2{Term=[expires], Sec=[execution timer]}]}
5414
5415 @begin{ImplNote}
5416 @ChgRef{Version=[2],Kind=[AddedNormal]}
5417 @ChgAdded{Version=[2],Text=[Since an access-to-constant can designate a
5418 variable, the Task_Id value designated by the discriminant of a Timer
5419 object can be changed after the object is created. Thus, an implementation
5420 cannot use the value of the Task_Id other than where this Standard specifies.
5421 For instance, the Task_Id should be read when the timer is set, but it
5422 should not be used when the timer expires (as it may designate a different
5423 task at that point).]}
5424 @end{ImplNote}
5425
5426 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5427 @ChgAdded{Version=[2],Text=[A call of a procedure Set_Handler for a timer that
5428 is already set replaces the handler and the (absolute or relative) execution
5429 time; if Handler is not @b<null>, the timer remains set.]}
5430
5431 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5432 @ChgAdded{Version=[2],Text=[When a timer expires, the associated handler is
5433 executed, passing the timer as parameter. The initial action of the execution
5434 of the handler is to clear the event.]}
5435
5436 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5437 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5438 @ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler
5439 associated with the timer TM if that timer is set;
5440 otherwise@Chg{Version=[3],New=[,],Old=[]} it returns @b<null>.]}
5441
5442 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5443 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5444 @ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the timer if it
5445 is set. Cancelled is assigned True if the timer was set prior to it being
5446 cleared; otherwise@Chg{Version=[3],New=[,],Old=[]}
5447 it is assigned False.]}
5448
5449 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5450 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5451 @ChgAdded{Version=[2],Text=[The function Time_Remaining returns the execution
5452 time interval that remains until the timer TM would expire, if that timer is
5453 set; otherwise@Chg{Version=[3],New=[,],Old=[]} it returns Time_Span_Zero.]}
5454
5455 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5456 @ChgAdded{Version=[2],Text=[The constant Min_Handler_Ceiling is the
5457 minimum ceiling priority required for a protected object with a handler to
5458 ensure that no ceiling violation will occur when that handler is invoked.]}
5459
5460 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5461 @ChgAdded{Version=[2],Text=[As part of the finalization of an object of type
5462 Timer, the timer is cleared.]}
5463
5464 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5465 @ChgAdded{Version=[2],Text=[For all the subprograms defined in this package,
5466 Tasking_Error is raised if the task identified by TM.T.@key[all] has terminated, and
5467 Program_Error is raised if the value of TM.T.@key[all] is
5468 Task_Identification.Null_Task_Id.]}
5469
5470 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5471 @ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked as
5472 part of the expiration of a timer has no effect.]}
5473
5474 @end{Runtime}
5475
5476 @begin{Erron}
5477
5478 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5479 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)}
5480 For a call of any of the subprograms defined in this package, if the task
5481 identified by TM.T.@key[all] no longer exists, the execution of the program is
5482 erroneous.]}
5483
5484 @end{Erron}
5485
5486 @begin{ImplReq}
5487
5488 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5489 @ChgAdded{Version=[2],Text=[For a given Timer object, the implementation shall
5490 perform the operations declared in this package atomically with respect to any
5491 of these operations on the same Timer object. The replacement of a handler by a
5492 call of Set_Handler shall be performed atomically with respect to the execution
5493 of the handler.]}
5494
5495 @begin{Reason}
5496 @ChgRef{Version=[2],Kind=[AddedNormal]}
5497 @ChgAdded{Version=[2],Text=[This prevents various race conditions. In
5498 particular it ensures that if an event occurs when Set_Handler is changing
5499 the handler then either the new or old handler is executed in response to the
5500 appropriate event. It is never possible for a new handler to be executed in
5501 response to an old event]}
5502 @end{Reason}
5503
5504 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5505 @ChgAdded{Version=[2],Text=[When an object of type Timer is finalized, the
5506 system resources used by the timer shall be deallocated.]}
5507
5508 @end{ImplReq}
5509
5510 @begin{ImplPerm}
5511
5512 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5513 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5514 @ChgAdded{Version=[2],Text=[Implementations may limit the number of timers that
5515 can be defined for each task. If this limit is exceeded@Chg{Version=[3],New=[,],Old=[]}
5516 then Timer_Resource_Error is raised.]}
5517
5518 @end{ImplPerm}
5519
5520 @begin{Notes}
5521
5522 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5523 @ChgAdded{Version=[2],Text=[A Timer_Handler can be associated with several
5524 Timer objects.]}
5525
5526 @end{Notes}
5527
5528 @begin{Extend95}
5529 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00307-01]}
5530 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
5531 The package Execution_Time.Timers is new.]}
5532 @end{Extend95}
5533
5534
5535 @RMNewPageVer{Version=[2]}@Comment{For printed RM Ada 2005}
5536 @ISOOnlyRMNewPageVer{Version=[3]}@Comment{For ISO version of Ada 2012 Standard}
5537 @LabeledAddedSubclause{Version=[2],Name=[Group Execution Time Budgets]}
5538
5539 @begin{Intro}
5540 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5541 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
5542 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
5543 describes a language-defined package to
5544 assign execution time budgets to groups of tasks.]}
5545 @end{Intro}
5546
5547 @begin{StaticSem}
5548 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5549 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
5550 language-defined library package exists:]}
5551 @begin{Example}
5552 @ChgRef{Version=[2],Kind=[AddedNormal]}
5553 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0169-1]}
5554 @ChgAdded{Version=[2],Text=[@key{with} System;@Chg{Version=[3],New=[
5555 @key{with} System.Multiprocessors;],Old=[]}
5556 @key{package} Ada.Execution_Time.Group_Budgets @key{is}@ChildUnit{Parent=[Ada.Execution_Time],Child=[Group_Budgets]}]}
5557
5558 @ChgRef{Version=[2],Kind=[AddedNormal]}
5559 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0092-1],ARef=[AI05-0169-1]}
5560 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Group_Budget}@Chg{Version=[3],New=[(CPU : System.Multiprocessors.CPU :=
5561 System.Multiprocessors.CPU'First)
5562 ],Old=[]} @key{is tagged limited private};]}
5563
5564 @ChgRef{Version=[2],Kind=[AddedNormal]}
5565 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Group_Budget_Handler} @key{is access}
5566 @key{protected procedure} (GB : @key{in out} Group_Budget);]}
5567
5568 @ChgRef{Version=[2],Kind=[AddedNormal]}
5569 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Task_Array} @key{is array} (Positive @key{range} <>) @key{of}
5570 Ada.Task_Identification.Task_Id;]}
5571
5572 @ChgRef{Version=[2],Kind=[AddedNormal]}
5573 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Min_Handler_Ceiling} : @key{constant} System.Any_Priority :=
5574 @RI[implementation-defined];]}
5575 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
5576 Text=[The value of Min_Handler_Ceiling in Execution_Time.Group_Budgets.]}]}
5577
5578 @ChgRef{Version=[2],Kind=[AddedNormal]}
5579 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Add_Task} (GB : @key{in out} Group_Budget;
5580 T : @key{in} Ada.Task_Identification.Task_Id);
5581 @key{procedure} @AdaSubDefn{Remove_Task} (GB: @key{in out} Group_Budget;
5582 T : @key{in} Ada.Task_Identification.Task_Id);
5583 @key{function} @AdaSubDefn{Is_Member} (GB : Group_Budget;
5584 T : Ada.Task_Identification.Task_Id) @key{return} Boolean;
5585 @key{function} @AdaSubDefn{Is_A_Group_Member}
5586 (T : Ada.Task_Identification.Task_Id) @key{return} Boolean;
5587 @key{function} @AdaSubDefn{Members} (GB : Group_Budget) @key{return} Task_Array;]}
5588
5589 @ChgRef{Version=[2],Kind=[AddedNormal]}
5590 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replenish} (GB : @key{in out} Group_Budget; To : @key{in} Time_Span);
5591 @key{procedure} @AdaSubDefn{Add} (GB : @key{in out} Group_Budget; Interval : @key{in} Time_Span);
5592 @key{function} @AdaSubDefn{Budget_Has_Expired} (GB : Group_Budget) @key{return} Boolean;
5593 @key{function} @AdaSubDefn{Budget_Remaining} (GB : Group_Budget) @key{return} Time_Span;]}
5594
5595 @ChgRef{Version=[2],Kind=[AddedNormal]}
5596 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (GB : @key{in out} Group_Budget;
5597 Handler : @key{in} Group_Budget_Handler);
5598 @key{function} @AdaSubDefn{Current_Handler} (GB : Group_Budget)
5599 @key{return} Group_Budget_Handler;
5600 @key{procedure} @AdaSubDefn{Cancel_Handler} (GB : @key{in out} Group_Budget;
5601 Cancelled : @key{out} Boolean);]}
5602
5603 @ChgRef{Version=[2],Kind=[AddedNormal]}
5604 @ChgAdded{Version=[2],Text=[ @AdaExcDefn{Group_Budget_Error} : @key{exception};]}
5605
5606 @ChgRef{Version=[2],Kind=[AddedNormal]}
5607 @ChgAdded{Version=[2],Text=[@key{private}
5608 -- @RI{not specified by the language}
5609 @key{end} Ada.Execution_Time.Group_Budgets;]}
5610
5611 @end{Example}
5612
5613 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5614 @ChgAdded{Version=[2],Text=[The type Group_Budget represents an execution time
5615 budget to be used by a group of tasks. The type Group_Budget
5616 needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
5617 (see @RefSecNum{Assignment and Finalization}). A task can belong
5618 to at most one group. Tasks of any priority can be added to a group.]}
5619
5620 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5621 @ChgAdded{Version=[2],Text=[An object of type Group_Budget has an associated
5622 nonnegative value of type Time_Span known as its @i<budget>, which is
5623 initially Time_Span_Zero. The type Group_Budget_Handler identifies a protected
5624 procedure to be executed by the implementation when the budget is
5625 @i<exhausted>, that is, reaches zero. Such a protected procedure is called a
5626 @i<handler>.@Defn{budget}@Defn2{Term=[exhaust],Sec=[a budget]}
5627 @PDefn2{Term=[handler],Sec=[group budget]}]}
5628
5629 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5630 @ChgAdded{Version=[2],Text=[An object of type Group_Budget also includes a
5631 handler, which is a value of type Group_Budget_Handler. The handler of the
5632 object is said to be @i<set> if it is not null and @i<cleared> otherwise. The
5633 handler of all Group_Budget objects is initially cleared.
5634 @PDefn2{Term=[set],Sec=[group budget object]}
5635 @PDefn2{Term=[clear],Sec=[group budget object]}]}
5636
5637 @begin{Discussion}
5638 @ChgRef{Version=[2],Kind=[AddedNormal]} @ChgAdded{Version=[2],Text=[Type
5639 Group_Budget is tagged. This makes it possible to share a handler between
5640 several events. In simple cases, 'Access can be used to compare the parameter
5641 with a specific group budget object (this works because a tagged type is a
5642 by-reference type). In more complex cases, a type extension of type
5643 Group_Budget can be declared; a double type conversion can be used to access
5644 the extension data. An example of how this can be done can be found for the
5645 similar type Timing_Event, see @RefSecNum{Timing Events}.]}
5646 @end{Discussion}
5647
5648 @end{StaticSem}
5649
5650 @begin{RunTime}
5651
5652 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5653 @ChgAdded{Version=[2],Text=[The procedure Add_Task adds the task identified by
5654 T to the group GB; if that task is already a member of some other group,
5655 Group_Budget_Error is raised.]}
5656
5657 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5658 @ChgAdded{Version=[2],Text=[The procedure Remove_Task removes the task
5659 identified by T from the group GB; if that task is not a member of the group
5660 GB, Group_Budget_Error is raised. After successful execution of this procedure,
5661 the task is no longer a member of any group.]}
5662
5663 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5664 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5665 @ChgAdded{Version=[2],Text=[The function Is_Member returns True if the task
5666 identified by T is a member of the group GB;
5667 otherwise@Chg{Version=[3],New=[,],Old=[]} it
5668 @Chg{Version=[3],New=[returns],Old=[return]} False.]}
5669
5670 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5671 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5672 @ChgAdded{Version=[2],Text=[The function Is_A_Group_Member returns True if the
5673 task identified by T is a member of some group;
5674 otherwise@Chg{Version=[3],New=[,],Old=[]} it returns False.]}
5675
5676 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5677 @ChgAdded{Version=[2],Text=[The function Members returns an array of values of
5678 type Task_Identification.Task_Id identifying the members of the group GB. The
5679 order of the components of the array is unspecified.]}
5680
5681 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5682 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0092-1],ARef=[AI05-0169-1]}
5683 @ChgAdded{Version=[2],Text=[The procedure Replenish loads the group budget GB
5684 with To as the Time_Span value. The exception Group_Budget_Error is raised if
5685 the Time_Span value To is nonpositive. Any execution @Chg{Version=[3],New=[on
5686 CPU ],Old=[]}of any member of the
5687 group of tasks results in the budget counting down, unless exhausted. When the
5688 budget becomes exhausted (reaches Time_Span_Zero), the associated handler is
5689 executed if the handler of group budget GB is set. Nevertheless, the tasks
5690 continue to execute.]}
5691
5692 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5693 @ChgAdded{Version=[2],Text=[The procedure Add modifies the budget of the group
5694 GB. A positive value for Interval increases the budget. A negative value for
5695 Interval reduces the budget, but never below Time_Span_Zero. A zero value for
5696 Interval has no effect. A call of procedure Add that results in the value of
5697 the budget going to Time_Span_Zero causes the associated handler to be executed
5698 if the handler of the group budget GB is set.]}
5699
5700 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5701 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5702 @ChgAdded{Version=[2],Text=[The function Budget_Has_Expired returns True if the
5703 budget of group GB is exhausted (equal to Time_Span_Zero);
5704 otherwise@Chg{Version=[3],New=[,],Old=[]} it returns False.]}
5705
5706 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5707 @ChgAdded{Version=[2],Text=[The function Budget_Remaining returns the remaining
5708 budget for the group GB. If the budget is exhausted it returns Time_Span_Zero.
5709 This is the minimum value for a budget.]}
5710
5711 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5712 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5713 @ChgAdded{Version=[2],Text=[The procedure Set_Handler associates the handler
5714 Handler with the Group_Budget GB@Chg{Version=[3],New=[:],Old=[;]}
5715 if Handler is @b<null>, the handler of
5716 Group_Budget is cleared@Chg{Version=[3],New=[;],Old=[,]}
5717 otherwise@Chg{Version=[3],New=[,],Old=[]} it is set.]}
5718
5719 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5720 @ChgAdded{Version=[2],Text=[A call of Set_Handler for a Group_Budget that
5721 already has a handler set replaces the handler; if Handler is not @b<null>, the
5722 handler for Group_Budget remains set.]}
5723
5724 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5725 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5726 @ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler
5727 associated with the group budget GB if the handler for that group budget is
5728 set; otherwise@Chg{Version=[3],New=[,],Old=[]} it returns @b<null>.]}
5729
5730 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5731 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5732 @ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the handler for
5733 the group budget if it is set. Cancelled is assigned True if the handler for
5734 the group budget was set prior to it being cleared;
5735 otherwise@Chg{Version=[3],New=[,],Old=[]} it is assigned False.]}
5736
5737 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5738 @ChgAdded{Version=[2],Text=[The constant Min_Handler_Ceiling is the
5739 minimum ceiling priority required for a protected object with a handler to
5740 ensure that no ceiling violation will occur when that handler is invoked.]}
5741
5742 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5743 @ChgAdded{Version=[2],Text=[The precision of the accounting of task execution
5744 time to a Group_Budget is the same as that defined for execution-time clocks
5745 from the parent package.]}
5746
5747 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5748 @ChgAdded{Version=[2],Text=[As part of the finalization of an object of type
5749 Group_Budget all member tasks are removed from the group identified by that
5750 object.]}
5751
5752 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5753 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5754 @ChgAdded{Version=[2],Text=[If a task is a member of a Group_Budget when it
5755 terminates@Chg{Version=[3],New=[,],Old=[]} then
5756 as part of the finalization of the task it is removed from the group.]}
5757
5758 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5759 @ChgAdded{Version=[2],Text=[For all the operations defined in this package,
5760 Tasking_Error is raised if the task identified by T has terminated, and
5761 Program_Error is raised if the value of T is
5762 Task_Identification.Null_Task_Id.]}
5763
5764 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5765 @ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked when
5766 the budget of a group of tasks becomes exhausted has no effect.]}
5767
5768 @end{RunTime}
5769
5770 @begin{Erron}
5771 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5772 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(erroneous execution),Sec=(cause)}
5773 For a call of any of the subprograms defined in this package, if the task
5774 identified by T no longer exists, the execution of the program is erroneous.]}
5775 @end{Erron}
5776
5777 @begin{ImplReq}
5778 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5779 @ChgAdded{Version=[2],Text=[For a given Group_Budget object, the implementation
5780 shall perform the operations declared in this package atomically with respect
5781 to any of these operations on the same Group_Budget object. The replacement of
5782 a handler, by a call of Set_Handler, shall be performed atomically with respect
5783 to the execution of the handler.]}
5784 @begin{Reason}
5785 @ChgRef{Version=[2],Kind=[AddedNormal]}
5786 @ChgAdded{Version=[2],Text=[This prevents various race conditions. In
5787 particular it ensures that if the budget is exhausted when Set_Handler
5788 is changing the handler then either the new or old handler is executed
5789 and the exhausting event is not lost.]}
5790 @end{Reason}
5791 @end{ImplReq}
5792
5793 @begin{Notes}
5794 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5795 @ChgAdded{Version=[2],Text=[Clearing or setting of the handler of a group
5796 budget does not change the current value of the budget. Exhaustion or loading
5797 of a budget does not change whether the handler of the group budget is set or
5798 cleared.]}
5799
5800 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5801 @ChgAdded{Version=[2],Text=[A Group_Budget_Handler can be associated with
5802 several Group_Budget objects.]}
5803 @end{Notes}
5804
5805 @begin{Extend95}
5806 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00354-01]}
5807 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
5808 The package Execution_Time.Group_Budgets is new.]}
5809 @end{Extend95}
5810
5811 @begin{Inconsistent2005}
5812 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0169-1]}
5813 @ChgAdded{Version=[3],Text=[@Defn{inconsistencies with Ada 2005}
5814 A Group_Budget is now defined to work on a single processor.
5815 If an implementation managed to make this package work for
5816 programs running on a multiprocessor system, and a program
5817 depends on that fact, it could fail when ported to Ada 2012.
5818 We believe it is unlikely that such an implementation exists
5819 because of the difficulty of signalling other processors when
5820 the time reaches zero; in any case, depending on such an
5821 implementation is not portable.]}
5822 @end{Inconsistent2005}
5823
5824
5825 @LabeledAddedSubClause{Version=[3],Name=[Execution Time of Interrupt Handlers]}
5826
5827 @begin{Intro}
5828 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5829 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
5830 @ChgAdded{Version=[3],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
5831 describes a language-defined package to
5832 measure the execution time of interrupt handlers.]}
5833 @end{Intro}
5834
5835 @begin{StaticSem}
5836 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5837 @ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The following
5838 language-defined library package exists:]}
5839 @begin{Example}
5840 @ChgRef{Version=[3],Kind=[AddedNormal]}
5841 @ChgAdded{Version=[3],Text=[@key{with} Ada.Interrupts;
5842 @key{package} Ada.Execution_Time.Interrupts @key{is}@ChildUnit{Parent=[Ada.Execution_Time],Child=[Interrupts]}
5843 @key{function} @AdaSubDefn{Clock} (Interrupt : Ada.Interrupts.Interrupt_Id)
5844 @key{return} CPU_Time;
5845 @key{function} @AdaSubDefn{Supported} (Interrupt : Ada.Interrupts.Interrupt_Id)
5846 @key{return} Boolean;
5847 @key{end} Ada.Execution_Time.Interrupts;]}
5848 @end{Example}
5849
5850 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5851 @ChgAdded{Version=[3],Text=[The execution time or CPU time of a given interrupt
5852 Interrupt is defined as the time spent by the system executing interrupt
5853 handlers identified by Interrupt, including the time spent executing run-time or
5854 system services on its behalf. The mechanism used to measure execution time is
5855 implementation defined. Time spent executing interrupt handlers is distinct from
5856 time spent executing any task.]}
5857 @begin{Discussion}
5858 @ChgRef{Version=[3],Kind=[AddedNormal]}
5859 @ChgAdded{Version=[3],Text=[The implementation-defined mechanism here is the
5860 same as that covered by the @DocReqTitle of @RefSecNum{Execution Time}, so we
5861 don't repeat that requirement here.]}
5862 @end{Discussion}
5863
5864 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5865 @ChgAdded{Version=[3],Text=[For each interrupt, the execution time value
5866 is initially set to zero.]}
5867 @end{StaticSem}
5868
5869 @begin{RunTime}
5870 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5871 @ChgAdded{Version=[3],Text=[The function Clock returns the current cumulative
5872 execution time of the interrupt identified by Interrupt. If
5873 Separate_Interrupt_Clocks_Supported is set to False the function raises
5874 Program_Error.]}
5875
5876 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1],ARef=[AI05-0264-1]}
5877 @ChgAdded{Version=[3],Text=[The function Supported returns True if the
5878 implementation is monitoring the execution time of the interrupt identified by
5879 Interrupt; otherwise, it returns False. For any Interrupt_Id Interrupt for which
5880 Supported(Interrupt) returns False, the function Clock(Interrupt) will return a
5881 value equal to Ada.Execution_Time.Time_Of(0).]}
5882
5883 @end{RunTime}
5884
5885 @begin{Extend2005}
5886 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0170-1]}
5887 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
5888 The package Execution_Time.Interrupts is new.]}
5889 @end{Extend2005}
5890
5891
5892 @LabeledAddedClause{Version=[2],Name=[Timing Events]}
5893
5894 @begin{Intro}
5895 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
5896 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
5897 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
5898 describes a language-defined package to
5899 allow user-defined protected procedures to be executed at a specified time
5900 without the need for a task or a delay statement.]}
5901 @end{Intro}
5902
5903 @begin{StaticSem}
5904 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
5905 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The following
5906 language-defined library package exists:]}
5907 @begin{Example}
5908 @ChgRef{Version=[2],Kind=[AddedNormal]}
5909 @ChgAdded{Version=[2],Text=[@key{package} Ada.Real_Time.Timing_Events @key{is}@ChildUnit{Parent=[Ada.Real_Time],Child=[Timing_Events]}]}
5910
5911 @ChgRef{Version=[2],Kind=[AddedNormal]}
5912 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Timing_Event} @key{is tagged limited private};
5913 @key{type} @AdaTypeDefn{Timing_Event_Handler}
5914 @key{is access protected procedure} (Event : @key{in out} Timing_Event);]}
5915
5916 @ChgRef{Version=[2],Kind=[AddedNormal]}
5917 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Handler} (Event : @key{in out} Timing_Event;
5918 At_Time : @key{in} Time;
5919 Handler : @key{in} Timing_Event_Handler);
5920 @key{procedure} @AdaSubDefn{Set_Handler} (Event : @key{in out} Timing_Event;
5921 In_Time : @key{in} Time_Span;
5922 Handler : @key{in} Timing_Event_Handler);
5923 @key{function} @AdaSubDefn{Current_Handler} (Event : Timing_Event)
5924 @key{return} Timing_Event_Handler;
5925 @key{procedure} @AdaSubDefn{Cancel_Handler} (Event : @key{in out} Timing_Event;
5926 Cancelled : @key{out} Boolean);]}
5927
5928 @ChgRef{Version=[2],Kind=[AddedNormal]}
5929 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Time_Of_Event} (Event : Timing_Event) @key{return} Time;]}
5930
5931 @ChgRef{Version=[2],Kind=[AddedNormal]}
5932 @ChgAdded{Version=[2],Text=[@key{private}
5933 ... -- @RI[not specified by the language]
5934 @key{end} Ada.Real_Time.Timing_Events;]}
5935 @end{Example}
5936
5937 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
5938 @ChgAdded{Version=[2],Text=[The type Timing_Event represents a time in the future
5939 when an event is to occur. The type Timing_Event
5940 needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
5941 (see @RefSecNum{Assignment and Finalization}).]}
5942
5943 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
5944 @ChgAdded{Version=[2],Text=[An object of type Timing_Event is said to be
5945 @i<set> if it is associated with a nonnull value of type Timing_Event_Handler
5946 and @i<cleared> otherwise. All Timing_Event objects are initially cleared.
5947 @PDefn2{Term=[set],Sec=[timing event object]}
5948 @PDefn2{Term=[clear],Sec=[timing event object]}]}
5949
5950 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
5951 @ChgAdded{Version=[2],Text=[The type Timing_Event_Handler identifies a
5952 protected procedure to be executed by the implementation when the timing event
5953 occurs. Such a protected procedure is called a @i{handler}.
5954 @PDefn2{Term=[handler],Sec=[timing event]}]}
5955
5956 @begin{Discussion}
5957 @ChgRef{Version=[2],Kind=[AddedNormal]}
5958 @ChgAdded{Version=[2],Type=[Leading],Text=[Type Timing_Event is tagged. This
5959 makes it possible to share a handler between several events. In simple cases,
5960 'Access can be used to compare the parameter with a specific timing event
5961 object (this works because a tagged type is a by-reference type). In more
5962 complex cases, a type extension of type Timing_Event can be declared; a
5963 double type conversion can be used to access the extension data. For
5964 example:]}
5965
5966 @begin{Example}
5967 @ChgRef{Version=[2],Kind=[AddedNormal]}
5968 @ChgAdded{Version=[2],Text=[@key{type} Toaster_Timing_Event @key{is new} Timing_Event @key{with record}
5969 Slot : Natural;
5970 @key{end record};]}
5971
5972 @ChgRef{Version=[2],Kind=[AddedNormal]}
5973 @ChgAdded{Version=[2],Text=[...]}
5974
5975 @ChgRef{Version=[2],Kind=[AddedNormal]}
5976 @ChgAdded{Version=[2],Text=[@key{protected body} Toaster @key{is}]}
5977
5978 @ChgRef{Version=[2],Kind=[AddedNormal]}
5979 @ChgAdded{Version=[2],Text=[ @key{procedure} Timer (Event : @key{in out} Timing_Event) @key{is}
5980 @key{begin}
5981 Pop_Up_Toast (Toaster_Timing_Event(Timing_Event'Class(Event)).Slot);
5982 @key{end} Timer;]}
5983
5984 @ChgRef{Version=[2],Kind=[AddedNormal]}
5985 @ChgAdded{Version=[2],Text=[ ...
5986 @key{end} Toaster;]}
5987 @end{Example}
5988
5989 @ChgRef{Version=[2],Kind=[AddedNormal]}
5990 @ChgAdded{Version=[2],Text=[The extra conversion to the class-wide type
5991 is necessary to make the conversions legal. While this usage is clearly
5992 ugly, we think that the need for this sort of usage will be rare, so
5993 we can live with it. It's certainly better than having no way to associate
5994 data with an event.]}
5995 @end{Discussion}
5996
5997 @end{StaticSem}
5998
5999 @begin{Runtime}
6000
6001 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6002 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6003 @ChgAdded{Version=[2],Text=[The procedures Set_Handler associate the handler
6004 Handler with the event Event@Chg{Version=[3],New=[:],Old=[;]} if Handler
6005 is @key{null}, the event is cleared@Chg{Version=[3],New=[;],Old=[,]}
6006 otherwise@Chg{Version=[3],New=[,],Old=[]} it is set. The first procedure
6007 Set_Handler sets the execution time for the event to be At_Time. The second
6008 procedure Set_Handler sets the execution time for the event to be
6009 Real_Time.Clock + In_Time.]}
6010
6011 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6012 @ChgAdded{Version=[2],Text=[A call of a procedure Set_Handler for an event that
6013 is already set replaces the handler and the time of execution; if Handler is
6014 not @key{null}, the event remains set.]}
6015
6016 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6017 @ChgAdded{Version=[2],Text=[As soon as possible after the time set for the
6018 event, the handler is executed, passing the event as parameter. The handler is
6019 only executed if the timing event is in the set state at the time of execution.
6020 The initial action of the execution of the handler is to clear the event.]}
6021
6022 @begin{Reason}
6023 @ChgRef{Version=[2],Kind=[AddedNormal]}
6024 @ChgAdded{Version=[2],Text=[The second sentence of this paragraph is because
6025 of a potential race condition. The time might expire and yet before the
6026 handler is executed, some task could call Cancel_Handler (or equivalently
6027 call Set_Handler with a @key{null} parameter) and thus clear the handler.]}
6028 @end{Reason}
6029
6030 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6031 @ChgAdded{Version=[2],Text=[If the Ceiling_Locking policy (see
6032 @RefSecNum{Priority Ceiling Locking}) is in effect when a procedure
6033 Set_Handler is called, a check is made that the ceiling priority of
6034 Handler.@key{all} is Interrupt_Priority'Last. If the check fails, Program_Error
6035 is raised.]}
6036
6037 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6038 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0094-1],ARef=[AI05-0264-1]}
6039 @ChgAdded{Version=[2],Text=[If a procedure Set_Handler is called with zero or
6040 negative In_Time or with At_Time indicating a time in the
6041 past@Chg{Version=[3],New=[,],Old=[]} then the handler
6042 is executed @Chg{Version=[3],New=[as soon as possible after the completion of],
6043 Old=[immediately by the task executing]} the call of Set_Handler.@Chg{Version=[3],
6044 New=[],Old=[ The timing event Event is cleared.]}]}
6045
6046 @begin{Ramification}
6047 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0094-1]}
6048 @ChgAdded{Version=[3],Text=[The handler will still be executed. Under no
6049 circumstances is a scheduled call of a handler lost.]}
6050 @end{Ramification}
6051
6052 @begin{Discussion}
6053 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0094-1]}
6054 @ChgAdded{Version=[3],Text=[We say @ldquote@;as soon as possible@rdquote
6055 so that we do not deadlock if we are executing the handler when Set_Handler is
6056 called. In that case, the current invocation of the handler must complete
6057 before the new handler can start executing.]}
6058 @end{Discussion}
6059
6060 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6061 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6062 @ChgAdded{Version=[2],Text=[The function Current_Handler returns the handler
6063 associated with the event Event if that event is set;
6064 otherwise@Chg{Version=[3],New=[,],Old=[]} it returns @key{null}.]}
6065
6066 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6067 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6068 @ChgAdded{Version=[2],Text=[The procedure Cancel_Handler clears the event if it
6069 is set. Cancelled is assigned True if the event was set prior to it being
6070 cleared; otherwise@Chg{Version=[3],New=[,],Old=[]} it is assigned False.]}
6071
6072 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6073 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6074 @ChgAdded{Version=[2],Text=[The function Time_Of_Event returns the time of the
6075 event if the event is set;
6076 otherwise@Chg{Version=[3],New=[,],Old=[]} it returns Real_Time.Time_First.]}
6077
6078 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6079 @ChgAdded{Version=[2],Text=[As part of the finalization of an object
6080 of type Timing_Event, the Timing_Event is cleared.]}
6081
6082 @begin{ImplNote}
6083 @ChgRef{Version=[2],Kind=[AddedNormal]}
6084 @ChgAdded{Version=[2],Text=[This is the only finalization defined by the
6085 language that has a visible effect; but an implementation may have other
6086 finalization that it needs to perform. Implementations need to ensure that
6087 the event is cleared before anything else is finalized that would prevent
6088 a set event from being triggered.]}
6089 @end{ImplNote}
6090
6091 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6092 @ChgAdded{Version=[2],Text=[If several timing events are set for the same time,
6093 they are executed in FIFO order of being set.]}
6094
6095 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6096 @ChgAdded{Version=[2],Text=[An exception propagated from a handler invoked by a
6097 timing event has no effect.]}
6098
6099 @end{Runtime}
6100
6101 @begin{ImplReq}
6102
6103 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6104 @ChgAdded{Version=[2],Text=[For a given Timing_Event object, the implementation
6105 shall perform the operations declared in this package atomically with respect
6106 to any of these operations on the same Timing_Event object. The replacement of
6107 a handler by a call of Set_Handler shall be performed atomically with respect
6108 to the execution of the handler.]}
6109
6110 @begin{Reason}
6111 @ChgRef{Version=[2],Kind=[AddedNormal]}
6112 @ChgAdded{Version=[2],Text=[This prevents various race conditions. In
6113 particular it ensures that if an event occurs when Set_Handler is changing
6114 the handler then either the new or old handler is executed in response to the
6115 appropriate event. It is never possible for a new handler to be executed in
6116 response to an old event.]}
6117 @end{Reason}
6118 @end{ImplReq}
6119
6120 @begin{Metrics}
6121
6122 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6123 @ChgAdded{Version=[2],Type=[Leading],Text=[The implementation shall document
6124 the following metric:]}
6125 @begin{Itemize}
6126
6127 @ChgRef{Version=[2],Kind=[AddedNormal]}
6128 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0210-1]}
6129 @ChgAdded{Version=[2],Text=[An upper bound on the lateness of the execution of
6130 a handler. That is, the maximum time between @Chg{Version=[3],New=[the time specified
6131 for the event and ],Old=[]}when a handler is actually
6132 @Chg{Version=[3],New=[invoked assuming no other handler or task is executing
6133 during this interval],Old=[executed and the time specified when the event was
6134 set]}.]}
6135
6136 @end{Itemize}
6137 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
6138 Text=[The metrics for timing events.]}]}
6139 @end{Metrics}
6140
6141 @begin{ImplAdvice}
6142
6143 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6144 @ChgAdded{Version=[2],Text=[The protected handler procedure should be executed
6145 directly by the real-time clock interrupt mechanism.]}
6146
6147 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
6148 Text=[For a timing event, the handler should be executed directly by the
6149 real-time clock interrupt mechanism.]}]}
6150
6151 @end{ImplAdvice}
6152
6153 @begin{Notes}
6154
6155 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6156 @ChgAdded{Version=[2],Text=[Since a call of Set_Handler is not a potentially
6157 blocking operation, it can be called from within a handler.]}
6158
6159 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6160 @ChgAdded{Version=[2],Text=[A Timing_Event_Handler can be associated with several
6161 Timing_Event objects.]}
6162
6163 @end{Notes}
6164
6165 @begin{Extend95}
6166 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00297-01]}
6167 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
6168 The package Real_Time.Timing_Events is new.]}
6169 @end{Extend95}
6170
6171 @begin{Diffword2005}
6172 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0094-1]}
6173 @ChgAdded{Version=[3],Text=[@b<Correction:> Reworded to eliminate a
6174 deadlock condition if the event time is in the past and a handler is currently
6175 executing. This is technically an inconsistency, but only if a program is
6176 depending on deadlocking; since it is impossible to imagine how that could
6177 be useful, we have not documented this as an inconsistency.]}
6178
6179 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0210-1]}
6180 @ChgAdded{Version=[3],Text=[@b<Correction:> Clarified the metric for lateness
6181 of a timing event to exclude interference from other handlers and tasks.
6182 This change might change the documentation of an implementation, but not
6183 the implementation itself, so there is no inconsistency.]}
6184 @end{Diffword2005}
6185
6186
6187 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
6188 @LabeledAddedClause{Version=[3],Name=[Multiprocessor Implementation]}
6189
6190 @begin{Intro}
6191 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
6192 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
6193 @ChgAdded{Version=[3],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
6194 allows implementations on multiprocessor platforms to be configured.]}
6195 @end{Intro}
6196
6197 @begin{StaticSem}
6198
6199 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
6200 @ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The following
6201 language-defined library package exists:]}
6202 @begin{Example}
6203 @ChgRef{Version=[3],Kind=[AddedNormal]}
6204 @ChgAdded{Version=[3],Text=[@key[package] System.Multiprocessors @key{is}@ChildUnit{Parent=[System],Child=[Multiprocessors]}
6205 @key[pragma] Preelaborate(Multiprocessors);]}
6206
6207 @ChgRef{Version=[3],Kind=[AddedNormal]}
6208 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{CPU_Range} @key[is range] 0 .. @RI<implementation-defined>;
6209 @AdaObjDefn{Not_A_Specific_CPU} : @key[constant] CPU_Range := 0;
6210 @key[subtype] @AdaSubtypeDefn{Name=[CPU],Of=[CPU_Range]} @key[is] CPU_Range @key[range] 1 .. CPU_Range'Last;]}
6211 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
6212 Text=[The value of CPU_Range'Last in System.Multiprocessors.]}]}
6213
6214 @ChgRef{Version=[3],Kind=[AddedNormal]}
6215 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Number_Of_CPUs} @key[return] CPU;
6216 @key[end] System.Multiprocessors;]}
6217 @end{Example}
6218
6219 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1]}
6220 @ChgAdded{Version=[3],Text=[A call of Number_Of_CPUs returns the number of
6221 processors available to the program. Within a given partition, each call on
6222 Number_Of_CPUs will return the same value.]}
6223
6224 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
6225 @ChgAdded{Version=[3],Type=[Leading],Text=[For a task type (including the
6226 anonymous type of a @nt{single_task_declaration}) or subprogram, the following
6227 language-defined representation aspect may be specified:]}
6228
6229 @begin{Description}
6230 @ChgRef{Version=[3],Kind=[AddedNormal]}
6231 @ChgAdded{Version=[3],Text=[CPU@\The aspect CPU is an @nt{expression},
6232 which shall be of type System.Multiprocessors.CPU_Range.@AspectDefn{CPU}]}
6233
6234 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[CPU],
6235 Text=[@ChgAdded{Version=[3],Text=[Processor on which a given task should
6236 run.]}]}
6237
6238 @end{Description}
6239 @end{StaticSem}
6240
6241 @begin{Legality}
6242
6243 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
6244 @ChgAdded{Version=[3],Text=[If the CPU aspect is specified for a subprogram,
6245 the @nt{expression} shall be static.]}
6246
6247 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
6248 @ChgAdded{Version=[3],Text=[The CPU aspect shall not be specified on a task
6249 interface type.]}
6250
6251 @end{Legality}
6252
6253 @begin{Runtime}
6254
6255 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
6256 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0081-1]}
6257 @ChgAdded{Version=[3],Text=[The @nt{expression} specified for the CPU aspect
6258 of a task@Chg{Version=[4],New=[ type],Old=[]} is evaluated
6259 @Chg{Version=[4],New=[],Old=[for ]}each
6260 @Chg{Version=[4],New=[time an],Old=[task]} object
6261 @Chg{Version=[4],New=[of the task type is created ],Old=[]}(see
6262 @RefSecNum{Task Units and Task Objects}). The CPU value is then associated with
6263 the task object@Chg{Version=[4],New=[],Old=[ whose task declaration specifies
6264 the aspect]}.]}
6265
6266 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
6267 @ChgAdded{Version=[3],Text=[The CPU aspect has no effect if it is specified for
6268 a subprogram other than the main subprogram;
6269 the CPU value is not associated with any task.]}
6270
6271 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
6272 @ChgAdded{Version=[3],Text=[The CPU value is associated with the environment
6273 task if the CPU aspect is specified for the main subprogram.
6274 If the CPU aspect is not specified for the main subprogram it is implementation
6275 defined on which processor the environment task executes.]}
6276 @ChgImplDef{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
6277 Text=[The processor on which the environment task executes in the absence of a
6278 value for the aspect CPU.]}]}
6279
6280 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0264-1]}
6281 @ChgAdded{Version=[3],Text=[The CPU value determines the processor on which the
6282 task will activate and execute; the task is said to be assigned to that
6283 processor. If the CPU value is Not_A_Specific_CPU, then the task is not assigned
6284 to a processor. A task without a CPU aspect specified will activate and execute on the
6285 same processor as its activating task if the activating task is assigned a
6286 processor. If the CPU value is not in the range of
6287 System.Multiprocessors.CPU_Range or is greater than Number_Of_CPUs the task is
6288 defined to have failed, and it becomes a completed task (see
6289 @RefSecNum{Task Execution - Task Activation}).]}
6290
6291 @end{Runtime}
6292
6293 @begin{Extend2005}
6294 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0171-1],ARef=[AI05-0229-1]}
6295 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
6296 The package System.Multiprocessors and the CPU aspect are new.]}
6297 @end{Extend2005}
6298
6299 @begin{DiffWord2012}
6300 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0081-1]}
6301 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified when the CPU
6302 aspect expression is evaluated.]}
6303 @end{DiffWord2012}
6304
6305
6306 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
6307 @LabeledAddedSubClause{Version=[3],Name=[Multiprocessor Dispatching Domains]}
6308
6309 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1],ARef=[AI05-0299-1]}
6310 @ChgAdded{Version=[3],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
6311 allows implementations on multiprocessor
6312 platforms to be partitioned into distinct dispatching domains during program
6313 startup.]}
6314
6315 @begin{StaticSem}
6316
6317 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6318 @ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The following
6319 language-defined library package exists:]}
6320 @begin{Example}
6321 @ChgRef{Version=[3],Kind=[AddedNormal]}
6322 @ChgAdded{Version=[3],Text=[@key[with] Ada.Real_Time;
6323 @key[with] Ada.Task_Identification;
6324 @key[package] System.Multiprocessors.Dispatching_Domains @key{is}@ChildUnit{Parent=[System.Multiprocessors],Child=[Dispatching_Domains]}]}
6325
6326 @ChgRef{Version=[3],Kind=[AddedNormal]}
6327 @ChgAdded{Version=[3],Text=[ @AdaExcDefn{Dispatching_Domain_Error} : @key[exception];]}
6328
6329 @ChgRef{Version=[3],Kind=[AddedNormal]}
6330 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Dispatching_Domain} (<>) @key[is limited private];]}
6331
6332 @ChgRef{Version=[3],Kind=[AddedNormal]}
6333 @ChgAdded{Version=[3],Text=[ @AdaObjDefn{System_Dispatching_Domain} : @key[constant] Dispatching_Domain;]}
6334
6335 @ChgRef{Version=[3],Kind=[AddedNormal]}
6336 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6337 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Create} (First@Chg{Version=[4],New=[],Old=[, Last]} : CPU@Chg{Version=[4],New=[; Last : CPU_Range],Old=[]}) @key[return] Dispatching_Domain;]}
6338
6339 @ChgRef{Version=[3],Kind=[AddedNormal]}
6340 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Get_First_CPU} (Domain : Dispatching_Domain) @key[return] CPU;]}
6341
6342 @ChgRef{Version=[3],Kind=[AddedNormal]}
6343 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6344 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Get_Last_CPU} (Domain : Dispatching_Domain) @key[return] @Chg{Version=[4],New=[CPU_Range],Old=[CPU]};]}
6345
6346 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0033-1]}
6347 @ChgAdded{Version=[4],Text=[ @key[type] @AdaTypeDefn{CPU_Set} @key[is array](CPU @key[range] <>) @key[of] Boolean;]}
6348
6349 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0033-1]}
6350 @ChgAdded{Version=[4],Text=[ @key[function] @AdaSubDefn{Create} (Set : CPU_Set) @key[return] Dispatching_Domain;]}
6351
6352 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0033-1]}
6353 @ChgAdded{Version=[4],Text=[ @key[function] @AdaSubDefn{Get_CPU_Set} (Domain : Dispatching_Domain) @key[return] CPU_Set;]}
6354
6355 @ChgRef{Version=[3],Kind=[AddedNormal]}
6356 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Get_Dispatching_Domain}
6357 (T : Ada.Task_Identification.Task_Id :=
6358 Ada.Task_Identification.Current_Task)
6359 @key[return] Dispatching_Domain;]}
6360
6361 @ChgRef{Version=[3],Kind=[AddedNormal]}
6362 @ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Assign_Task}
6363 (Domain : @key[in out] Dispatching_Domain;
6364 CPU : @key[in] CPU_Range := Not_A_Specific_CPU;
6365 T : @key[in] Ada.Task_Identification.Task_Id :=
6366 Ada.Task_Identification.Current_Task);]}
6367
6368 @ChgRef{Version=[3],Kind=[AddedNormal]}
6369 @ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Set_CPU}
6370 (CPU : @key[in] CPU_Range;
6371 T : @key[in] Ada.Task_Identification.Task_Id :=
6372 Ada.Task_Identification.Current_Task);]}
6373
6374 @ChgRef{Version=[3],Kind=[AddedNormal]}
6375 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Get_CPU}
6376 (T : Ada.Task_Identification.Task_Id :=
6377 Ada.Task_Identification.Current_Task)
6378 @key[return] CPU_Range;]}
6379
6380 @ChgRef{Version=[3],Kind=[AddedNormal]}
6381 @ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Delay_Until_And_Set_CPU}
6382 (Delay_Until_Time : @key[in] Ada.Real_Time.Time; CPU : @key[in] CPU_Range);]}
6383
6384 @ChgRef{Version=[3],Kind=[AddedNormal]}
6385 @ChgAdded{Version=[3],Text=[@key[private]
6386 ... -- @RI[not specified by the language]
6387 @key[end] System.Multiprocessors.Dispatching_Domains;]}
6388 @end{Example}
6389
6390 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6391 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0082-1]}
6392 @ChgAdded{Version=[3],Text=[@Chg{Version=[4],New=[A @i{dispatching
6393 domain}@Defn{dispatching domain}],Old=[The type Dispatching_Domain]}
6394 represents a @Chg{Version=[4],New=[set],Old=[series]}
6395 of processors on which a task may execute. Each processor
6396 is contained within exactly one @Chg{Version=[4],New=[dispatching
6397 domain],Old=[Dispatching_Domain]}.
6398 @Chg{Version=[4],New=[An object of type Dispatching_Domain identifies a
6399 dispatching domain. ],Old=[]}System_Dispatching_Domain
6400 @Chg{Version=[4],New=[identifies a domain that ],Old=[]}contains the processor
6401 or processors on which the environment task executes. At program start-up all
6402 processors are contained within
6403 @Chg{Version=[4],New=[this domain],Old=[System_Dispatching_Domain]}.]}
6404
6405 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6406 @ChgAdded{Version=[3],Type=[Leading],Text=[For a task type (including the
6407 anonymous type of a @nt{single_task_declaration}), the following language-defined
6408 representation aspect may be specified:]}
6409
6410 @begin{Description}
6411 @ChgRef{Version=[3],Kind=[AddedNormal]}
6412 @ChgAdded{Version=[3],Text=[Dispatching_Domain@\The value of
6413 aspect Dispatching_Domain is an @nt{expression}, which shall be of
6414 type Dispatching_Domains.Dispatching_Domain. This aspect is the domain to
6415 which the task (or all objects of the task type) are
6416 assigned.@AspectDefn{Dispatching_Domain}]}
6417
6418 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Dispatching_Domain],
6419 Text=[@ChgAdded{Version=[3],Text=[Domain (group of processors) on which a
6420 given task should run.]}]}
6421
6422 @end{Description}
6423 @end{StaticSem}
6424
6425 @begin{Legality}
6426
6427 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6428 @ChgAdded{Version=[3],Text=[The Dispatching_Domain aspect shall not be specified
6429 for a task interface.]}
6430
6431 @end{Legality}
6432
6433 @begin{Runtime}
6434
6435 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6436 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6437 @ChgAdded{Version=[3],Text=[The expression specified for the Dispatching_Domain
6438 aspect of a task @Chg{Version=[4],New=[type ],Old=[]}is evaluated
6439 @Chg{Version=[4],New=[each time an object of the task type is created],Old=[for
6440 each task object]} (see @RefSecNum{Task Units and Task Objects}).
6441 @Chg{Version=[4],New=[If the identified dispatching domain is empty, then
6442 Dispatching_Domain_Error is raised; otherwise the newly created task is assigned
6443 to the domain identified by the value of the expression],Old=[The
6444 Dispatching_Domain value is then associated with the task object whose task
6445 declaration specifies the aspect]}.]}
6446
6447 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6448 @ChgAdded{Version=[3],Text=[If a task is not explicitly assigned to any domain,
6449 it is assigned to that of the activating task. A task always executes on some
6450 CPU in its domain.]}
6451
6452 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6453 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0082-1]}
6454 @ChgAdded{Version=[3],Text=[If both @Chg{Version=[4],New=[the dispatching
6455 domain],Old=[Dispatching_Domain]} and CPU are specified for
6456 a task, and the CPU value is not contained within the
6457 @Chg{Version=[4],New=[set],Old=[range]} of processors for
6458 the domain (and is not Not_A_Specific_CPU), the activation of the task is
6459 defined to have failed, and it becomes a completed task (see
6460 @RefSecNum{Task Execution - Task Activation}).]}
6461
6462 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6463 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6464 @ChgAdded{Version=[3],Text=[The function Create @Chg{Version=[4],New=[with First
6465 and Last parameters ],Old=[]}creates and returns a @Chg{Version=[4],New=[dispatching
6466 domain],Old=[Dispatching_Domain]} containing
6467 all the processors in the range First .. Last. @Chg{Version=[4],New=[The
6468 function Create with a Set parameter creates and returns a dispatching domain
6469 containing the processors for which Set(I) is True.],Old=[]} These processors
6470 are removed from System_Dispatching_Domain. A call of Create will raise
6471 Dispatching_Domain_Error if any designated processor is not currently in
6472 System_Dispatching_Domain, or if the system cannot support a distinct domain
6473 over the processors identified, or if a processor has a task assigned to it, or
6474 if the allocation would leave System_Dispatching_Domain empty. A call of Create
6475 will raise Dispatching_Domain_Error if the calling task is not the environment
6476 task, or if Create is called after the call to the main subprogram.]}
6477
6478 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6479 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6480 @ChgAdded{Version=[3],Text=[The function Get_First_CPU returns the first CPU in
6481 Domain@Chg{Version=[4],New=[, or CPU'First if Domain is empty],Old=[]};
6482 Get_Last_CPU returns the last @Chg{Version=[4],New=[CPU in Domain, or
6483 CPU_Range'First if Domain is empty. The function Get_CPU_Set(D) returns an array
6484 whose low bound is Get_First_CPU(D), whose high bound is Get_Last_CPU(D), with
6485 True values in the Set corresponding to the CPUs that are in the given
6486 Domain],Old=[one]}.]}
6487
6488 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6489 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0082-1]}
6490 @ChgAdded{Version=[3],Text=[The function Get_Dispatching_Domain returns the
6491 @Chg{Version=[4],New=[dispatching domain],Old=[Dispatching_Domain]} on
6492 which the task is assigned.]}
6493
6494 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1],ARef=[AI05-0278-1]}
6495 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0033-1]}
6496 @ChgAdded{Version=[3],Text=[A call of the procedure Assign_Task assigns task T
6497 to the CPU within @Chg{Version=[4],New=[the dispatching domain],Old=[Dispatching_Domain]}
6498 Domain. Task T can now execute only on
6499 CPU@Chg{Version=[4],New=[,],Old=[]} unless CPU designates
6500 Not_A_Specific_CPU@Chg{Version=[4],New=[],Old=[,]} in which case it can
6501 execute on any processor within Domain. The exception Dispatching_Domain_Error
6502 is propagated if@Chg{Version=[4],New=[ Domain is empty,],Old=[]}
6503 T is already assigned to
6504 a @Chg{Version=[4],New=[dispatching domain],Old=[Dispatching_Domain]} other
6505 than System_Dispatching_Domain, or if CPU is not one of the processors of Domain (and
6506 is not Not_A_Specific_CPU). A call of Assign_Task is a task dispatching point
6507 for task T unless T is inside of a protected action, in which case the effect on
6508 task T is delayed until its next task dispatching point. If T is the
6509 Current_Task the effect is immediate if T is not inside a protected action,
6510 otherwise the effect is as soon as practical. Assigning a task
6511 @Chg{Version=[4],New=[already assigned ],Old=[]}to System_Dispatching_Domain
6512 @Chg{Version=[4],New=[],Old=[that is already assigned ]}to that domain has no
6513 effect.]}
6514
6515 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1],ARef=[AI05-0278-1]}
6516 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0082-1]}
6517 @ChgAdded{Version=[3],Text=[A call of procedure Set_CPU assigns task T to the
6518 CPU. Task T can now execute only on CPU, unless CPU designates
6519 Not_A_Specific_CPU, in which case it can execute on any processor within its
6520 @Chg{Version=[4],New=[dispatching domain],Old=[Dispatching_Domain]}. The
6521 exception Dispatching_Domain_Error is propagated if CPU is not one of the
6522 processors of the @Chg{Version=[4],New=[dispatching
6523 domain],Old=[Dispatching_Domain]} on which T is assigned (and is not
6524 Not_A_Specific_CPU). A call of Set_CPU is a task dispatching point for task T
6525 unless T is inside of a protected action, in which case the effect on task T is
6526 delayed until its next task dispatching point. If T is the Current_Task the
6527 effect is immediate if T is not inside a protected action, otherwise the effect
6528 is as soon as practical.]}
6529
6530 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6531 @ChgAdded{Version=[3],Text=[The function Get_CPU returns the processor assigned
6532 to task T, or Not_A_Specific_CPU if the task is not assigned to a processor.]}
6533
6534 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6535 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0082-1]}
6536 @ChgAdded{Version=[3],Text=[A call of Delay_Until_And_Set_CPU delays the calling
6537 task for the designated time and then assigns the task to the specified
6538 processor when the delay expires. The exception Dispatching_Domain_Error is
6539 propagated if P is not one of the processors of the calling task's
6540 @Chg{Version=[4],New=[dispatching domain],Old=[Dispatching_Domain]} (and is
6541 not Not_A_Specific_CPU).]}
6542
6543 @end{Runtime}
6544
6545 @begin{ImplReq}
6546
6547 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6548 @ChgAdded{Version=[3],Text=[The implementation shall perform the operations
6549 Assign_Task, Set_CPU, Get_CPU and Delay_Until_And_Set_CPU atomically with
6550 respect to any of these operations on the same dispatching_domain, processor or
6551 task.]}
6552
6553 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0048-1]}
6554 @ChgAdded{Version=[4],Text=[Any task that belongs to the system dispatching
6555 domain can execute on any CPU within that domain, unless the assignment of the
6556 task has been specified.]}
6557
6558 @begin{Reason}
6559 @ChgRef{Version=[4],Kind=[AddedNormal]}
6560 @ChgAdded{Version=[4],Text=[This ensures that priorities and deadlines are
6561 respected within the system dispatching domain. There is no such guarantee
6562 between different domains.]}
6563
6564 @ChgRef{Version=[4],Kind=[AddedNormal]}
6565 @ChgAdded{Version=[4],Text=[We only need to talk about the system dispatching
6566 domain here, because Assign_Task and Set_CPU already have such wording for
6567 tasks that are assigned explicitly to a dispatching domain and specify
6568 Not_a_Specific_CPU.]}
6569 @end{Reason}
6570
6571 @begin{Ramification}
6572 @ChgRef{Version=[4],Kind=[AddedNormal]}
6573 @ChgAdded{Version=[4],Text=[If no dispatching domains are created, all tasks
6574 can execute on all processors. (As always, implementation-defined dispatching
6575 policies may have other rules, so a partition that does not specify any
6576 language-defined dispatching policy may do anything at all and in particular
6577 does not need to follow this rule.]}
6578 @end{Ramification}
6579
6580 @begin{Discussion}
6581 @ChgRef{Version=[4],Kind=[AddedNormal]}
6582 @ChgAdded{Version=[4],Text=[A task can be assigned to a specific CPU by
6583 specifying the aspect CPU for a task, or by calling a dynamic operation like
6584 Set_CPU or Assign_Task.]}
6585 @end{Discussion}
6586
6587 @end{ImplReq}
6588
6589 @begin{ImplAdvice}
6590
6591 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6592 @ChgAdded{Version=[3],Text=[Each dispatching domain should have separate and
6593 disjoint ready queues.]}
6594
6595 @ChgImplAdvice{Version=[3],Kind=[AddedNormal],Text=[@ChgAdded{Version=[3],
6596 Text=[Each dispatching domain should have separate and
6597 disjoint ready queues.]}]}
6598
6599 @begin{Honest}
6600 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0048-1]}
6601 @ChgAdded{Version=[4],Text=[@ldquote@;Ready queue@rdquote here doesn't mean
6602 the conceptual "ready queue" as defined in @RefSecNum{The Task Dispatching Model}
6603 (one per processor); this rule is talking about the ready queues used by the
6604 implementation.]}
6605 @end{Honest}
6606
6607 @end{ImplAdvice}
6608
6609 @begin{DocReq}
6610
6611 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6612 @ChgAdded{Version=[3],Text=[The implementation shall document the processor(s)
6613 on which the clock interrupt is handled and hence where delay queue and ready
6614 queue manipulations occur. For any Interrupt_Id whose handler can execute on
6615 more than one processor the implementation shall also document this set of
6616 processors.]}
6617
6618 @ChgDocReq{Version=[3],Kind=[AddedNormal],Text=[@ChgAdded{Version=[3],
6619 Text=[The processor(s) on which the clock interrupt is handled; the processors
6620 on which each Interrupt_Id can be handled.]}]}
6621
6622 @end{DocReq}
6623
6624 @begin{ImplPerm}
6625
6626 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1]}
6627 @ChgAdded{Version=[3],Text=[An implementation may limit the number of
6628 dispatching domains that can be created and raise Dispatching_Domain_Error if an
6629 attempt is made to exceed this number.]}
6630
6631 @end{ImplPerm}
6632
6633 @begin{Extend2005}
6634 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0167-1],ARef=[AI05-0278-1]}
6635 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
6636 The package System.Multiprocessors.Dispatching_Domains and the aspect
6637 Dispatching_Domains are new.]}
6638 @end{Extend2005}
6639
6640 @begin{Inconsistent2012}
6641 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0033-1]}
6642 @ChgAdded{Version=[4],Text=[@Defn{inconsistencies with Ada 2012}
6643 @b{Corrigendum:} We now explicitly allow empty dispatching domains, as it
6644 would be difficult to avoid declaring them when a system is configured
6645 at runtime. Therefore, assigning a task to an empty domain now
6646 raises Dispatching_Domain_Error; creating such a domain should
6647 not raise Dispatching_Domain_Error. If an implementation does
6648 something different in these cases, and a program depends on
6649 that difference, the program could malfunction. This seems
6650 very unlikely (if no exception is ever raised, the task assigned
6651 to the empty domain could never run; if the exception is raised earlier,
6652 the program can't do anything useful).]}
6653 @end{Inconsistent2012}
6654
6655 @begin{Incompatible2012}
6656 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0033-1]}
6657 @ChgAdded{Version=[4],Text=[@Defn{incompatibilities with Ada 2012}@b<Corrigendum:>
6658 The subtypes of the parameter or result of several routines were changed
6659 to support empty domains. These changes will cause rules requiring
6660 subtype conformance to fail on these routines (such as 'Access). We
6661 believe such uses are unlikely. In addition, type CPU_Set and function
6662 Get_CPU_Set, along with an overloaded Create are newly added to this package.
6663 If Multiprocessors.Dispatching_Domains is referenced in a @nt{use_clause},
6664 and an entity @i<E> with the same @nt{defining_identifier} as a new entity
6665 in this package is defined in a package that is also referenced in a
6666 @nt{use_clause}, the entity @i<E> may no longer be use-visible, resulting
6667 in errors. This should be rare and is easily fixed if it does occur.]}
6668 @end{Incompatible2012}
6669
6670 @begin{Diffword2012}
6671 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0048-1]}
6672 @ChgAdded{Version=[4],Text=[@b{Corrigendum:} Added wording to clarify that
6673 all tasks can execute on all CPUs of the system dispatching domain by
6674 default.]}
6675
6676 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0082-1]}
6677 @ChgAdded{Version=[4],Text=[@b{Corrigndum:} Added a definition to clarify
6678 that a "dispatching domain" is a concept which is identified by an
6679 object of type Dispatching_Domain; more than one object might identify
6680 the same dispatching domain (for instance, the result of function
6681 Get_Dispatching_Domain is a different object but identifies the same
6682 dispatching domain).]}
6683 @end{Diffword2012}