Debian Codegraph @

source_2020/rt.mss

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