Debian Codegraph @

source_2012/ds.mss

raw
1 @comment{ $Source: e:\\cvsroot/ARM/Source/ds.mss,v $ }
2 @comment{ $Revision: 1.75 $ $Date: 2016/02/12 05:25:38 $ $Author: randy $ }
3 @Part(dist, Root="ada.mss")
4 @Comment{$Date: 2016/02/12 05:25:38 $}
5
6 @LabeledNormativeAnnex{Distributed Systems}
7
8 @begin{Intro}
9 @redundant[This Annex defines facilities for supporting the implementation
10 of distributed systems using multiple partitions working
11 cooperatively as part of a single Ada program.]
12 @end{Intro}
13
14 @begin{Extend83}
15 @Defn{extensions to Ada 83}
16 This Annex is new to Ada 95.
17 @end{Extend83}
18
19 @begin{LinkTime}
20
21 @Defn{processing node}
22 @Defn{storage node}
23 @Defn{distributed system}
24 A @i{distributed system} is an interconnection of one or more
25 @i{processing nodes} (a system resource that has both computational
26 and storage capabilities), and zero or more @i{storage nodes}
27 (a system resource that has only storage capabilities, with the storage
28 addressable by one or more processing nodes).
29
30 @Defn{distributed program}
31 A @i{distributed program} comprises one or more partitions that
32 execute independently (except when they communicate) in a distributed system.
33
34 @Defn2{Term=[configuration], Sec=(of the partitions of a program)}
35 The process of mapping the partitions of a program
36 to the nodes in a distributed system is
37 called @i{configuring the partitions of the program}.
38 @end{LinkTime}
39
40 @begin{ImplReq}
41
42 The implementation shall provide means for explicitly assigning library
43 units to a partition and for the configuring and execution of a program
44 consisting of multiple partitions on a distributed system;
45 the means are implementation defined.
46 @ImplDef{The means for creating and executing distributed programs.}
47
48 @end{ImplReq}
49
50 @begin{ImplPerm}
51
52 An implementation may require that the set of processing nodes of
53 a distributed system be homogeneous.
54
55 @end{ImplPerm}
56
57 @begin{Notes}
58
59
60 The partitions comprising a program may be executed on differently
61 configured distributed systems or on a nondistributed system without
62 requiring recompilation.
63 A distributed program may be partitioned differently from the same set of
64 library units without recompilation.
65 The resulting execution is semantically equivalent.
66
67 A distributed program retains the same type safety
68 as the equivalent single partition program.
69
70
71
72 @end{Notes}
73
74 @LabeledClause{Partitions}
75
76 @begin{Intro}
77 @redundant[The partitions of a distributed program are classified as either
78 active or passive.]
79 @end{Intro}
80
81 @begin{LinkTime}
82
83 @Defn{active partition}
84 @Defn{passive partition}
85 An @i{active partition} is a partition as defined in
86 @RefSecNum{Program Execution}. A @i{passive partition} is a partition
87 that has no thread of control of its own, whose
88 library units are all preelaborated, and whose data and subprograms are
89 accessible to one or more active partitions.
90 @begin{Discussion}
91 In most situations, a passive partition does not execute, and does not have
92 a @lquotes@;real@rquotes@; environment task. Any execution involved in
93 its elaboration and initialization occurs before it comes into existence in a
94 distributed program (like most preelaborated entities). Likewise,
95 there is no concrete meaning to passive partition termination.
96 @end{Discussion}
97
98 A passive partition shall include only @nt{library_item}s that either are
99 declared pure or are shared
100 passive (see @RefSecNum{Elaboration Control} and
101 @RefSecNum{Shared Passive Library Units}).
102
103 An active partition shall be configured on a processing node.
104 A passive partition shall be configured either on a storage node
105 or on a processing node.
106
107 The configuration of the partitions of a program onto a
108 distributed system shall
109 be consistent with the possibility for data references or calls
110 between the partitions implied by their semantic dependences.
111 @Defn{remote access}
112 Any reference to data or call of
113 a subprogram across partitions is called a @i{remote access}.
114 @begin{Discussion}
115 For example, an active partition that includes a unit with a semantic
116 dependence on the declaration of another RCI package of some other active
117 partition has to be connected to that other partition by some sort
118 of a message passing mechanism.
119
120 A passive partition that is accessible to an active partition should have
121 its storage addressable to the processor(s) of the active partition. The
122 processor(s) should be able to read and write from/to that
123 storage, as well as
124 to perform @lquotes@;read-modify-write@rquotes@; operations (in order to support entry-less
125 protected objects).
126
127 @end{Discussion}
128
129 @end{LinkTime}
130
131 @begin{RunTime}
132
133 @Defn2{Term=[elaboration], Sec=(partition)}
134 A @nt{library_item} is elaborated as part of the elaboration
135 of each partition that includes it.
136 If a normal library unit
137 (see @RefSecNum{Categorization of Library Units}) has state, then a separate
138 copy of the state exists in each active partition that elaborates it.
139 @Redundant[The state evolves independently in each such partition.]
140
141
142 @begin{Ramification}
143 Normal library units cannot be included in passive partitions.
144 @end{Ramification}
145
146 @Defn2{Term=[termination], Sec=(of a partition)}
147 @Defn2{Term=[abort], Sec=(of a partition)}
148 @Defn{inaccessible partition}
149 @Defn{accessible partition}
150 @Redundant[An active partition @i{terminates} when its environment task
151 terminates.] A partition becomes @i{inaccessible} if it terminates or if
152 it is @i{aborted}. An active partition is aborted when its environment
153 task is aborted. In addition, if a partition fails during its
154 elaboration, it becomes inaccessible to other partitions. Other
155 implementation-defined events can also result in a partition becoming
156 inaccessible.
157 @ImplDef{Any events that can result in a partition becoming
158 inaccessible.}
159
160 @ChgRef{Version=[1],Kind=[Revised]}@ChgNote{To be consistent with 8652/0006}
161 @Leading@;For @ChgPrefixType{Version=[1],Kind=[Revised],Text=[a
162 @Chg{New=[@nt{prefix}],Old=[prefix]} D that denotes a
163 library-level declaration,
164 excepting a declaration of or within a declared-pure library unit]},
165 the following attribute is defined:
166 @begin{Description}
167 @Attribute{Prefix=<D>, AttrName=<Partition_Id>,
168 Text=[Denotes a value of the type @i{universal_integer} that
169 identifies the partition in which D was elaborated.
170 If D denotes the declaration of a remote call interface
171 library unit
172 (see @RefSecNum{Remote Call Interface Library Units}) the
173 given partition is the one where the body of D was elaborated.]}
174 @end{Description}
175
176 @end{RunTime}
177
178 @begin{Bounded}
179 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00226-01]}
180 @PDefn2{Term=(bounded error),Sec=(cause)}
181 It is a bounded error for there to be cyclic elaboration dependences
182 between the active partitions of a single distributed
183 program.
184 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
185 The possible effects@Chg{Version=[2],New=[, in each of the partitions involved,],Old=[]}
186 are deadlock during elaboration, or the raising of
187 @Chg{Version=[2],New=[Communication_Error or ],Old=[]}Program_Error@Chg{Version=[2],
188 New=[],Old=[ in one or all of the active partitions involved]}.
189 @end{Bounded}
190
191 @begin{ImplPerm}
192
193 An implementation may allow multiple active or passive partitions
194 to be configured on
195 a single processing node, and multiple passive partitions to be
196 configured on a single storage node.
197 In these cases, the scheduling policies, treatment
198 of priorities, and management of shared resources between
199 these partitions are implementation defined.
200 @ImplDef{The scheduling policies, treatment
201 of priorities, and management of shared resources between
202 partitions in certain cases.}
203
204 An implementation may allow separate copies of an active partition to be
205 configured on different processing nodes, and to provide
206 appropriate interactions between the copies to present
207 a consistent state of the partition to other active partitions.
208 @begin{Ramification}
209 The language does not specify the nature of these interactions,
210 nor the actual level of consistency preserved.
211 @end{Ramification}
212
213 In an implementation, the partitions of a distributed
214 program need not be loaded and elaborated all at the same time;
215 they may be loaded and elaborated one at a time over an extended
216 period of time. An implementation may provide facilities to abort
217 and reload a partition during the execution of a distributed program.
218
219 An implementation may allow the state of some of the partitions of
220 a distributed program to persist while other partitions of the program
221 terminate and are later reinvoked.
222 @end{ImplPerm}
223
224 @begin{Notes}
225
226 Library units are grouped into partitions after compile time,
227 but before run time.
228 At compile time, only the relevant library unit properties are
229 identified using categorization pragmas.
230
231
232 The value returned by the Partition_Id attribute can be used as a
233 parameter to implementation-provided subprograms in order
234 to query information about the partition.
235
236 @end{Notes}
237
238 @begin{DiffWord95}
239 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00226-01]}
240 @ChgAdded{Version=[2],Text=[Corrected wording so that a partition that
241 has an elaboration problem will either deadlock or raise an exception.
242 While an Ada 95 implementation could allow some partitions to continue to
243 execute, they could be accessing unelaborated data, which is very bad
244 (and erroneous in a practical sense). Therefore, this isn't listed as an
245 inconsistency.]}
246 @end{DiffWord95}
247
248
249 @RMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
250 @LabeledClause{Categorization of Library Units}
251
252 @begin{Intro}
253 @redundant[Library units can be categorized according to the role
254 they play in a distributed program. Certain restrictions
255 are associated with each category to ensure that the semantics
256 of a distributed program remain close to the semantics for a nondistributed
257 program.]
258
259 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
260 @RootDefn{categorization pragma}
261 @RootDefn{pragma, categorization}
262 @PDefn2{Term=[library unit pragma], Sec=(categorization pragmas)}
263 @PDefn2{Term=[pragma, library unit], Sec=(categorization pragmas)}
264 @Chg{Version=[3],New=[@Defn{categorization aspect}],Old=[]}@Defn{categorized library unit}
265 A @i{categorization pragma} is a library unit pragma
266 (see @RefSecNum{Pragmas and Program Units})
267 that @Chg{Version=[3],New=[specifies a corresponding @i{categorization aspect}.
268 A categorization aspect ],Old=[]}restricts the declarations, child units, or
269 semantic dependences of the library unit to which it applies. A
270 @i{categorized library unit} is a library unit @Chg{Version=[3],New=[that has a
271 categorization aspect that is True],Old=[to which a categorization pragma
272 applies]}.
273
274 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
275 The pragmas Shared_Passive, Remote_Types, and Remote_Call_Interface
276 are categorization pragmas@Chg{Version=[3],New=[,
277 and the associated aspects are categorization aspects],Old=[]}.
278 In addition, for the purposes of this Annex, the @Chg{Version=[3],New=[aspect
279 Pure (see @RefSecNum{Elaboration Control}) is
280 considered a categorization aspect and the],Old=[]}
281 pragma Pure @Chg{Version=[3],New=[],Old=[(see @RefSecNum{Elaboration Control}) ]}is
282 considered a categorization pragma.
283
284 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
285 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
286 @Redundant[@Defn{shared passive library unit}
287 A library package or generic library package is called a
288 @i{shared passive} library unit if @Chg{Version=[3],New=[the],Old=[a]}
289 Shared_Passive @Chg{Version=[3],New=[aspect of the unit is True],Old=[pragma
290 applies to it]}. @Defn{remote types library unit} A library package or generic
291 library package is called a @i{remote types} library unit if
292 @Chg{Version=[3],New=[the],Old=[a]} Remote_Types @Chg{Version=[3],New=[aspect of
293 the unit is True],Old=[pragma applies to it]}. @Defn{remote call interface} A
294 library @Chg{New=[unit],Old=[package or generic library package]} is called a
295 @i{remote call interface} if @Chg{Version=[3],New=[the],Old=[a]}
296 Remote_Call_Interface @Chg{Version=[3],New=[aspect of the unit is
297 True],Old=[pragma applies to it]}.]
298 @Defn{normal library unit}
299 A @i{normal library unit} is one @Chg{Version=[3],New=[for],Old=[to]}
300 which no categorization
301 @Chg{Version=[3],New=[aspect is True],Old=[pragma applies]}.
302 @begin{TheProof}
303 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1],ARef=[AI05-0299-1]}
304 @ChgAdded{Version=[3],Text=[These terms (other than @ldquote@;normal
305 library unit@rdquote) are really defined in the following subclauses.]}
306 @end{TheProof}
307 @begin{Ramification}
308 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0078],ARef=[AI95-00048-01]}
309 @ChgAdded{Version=[1],Text=[A library subprogram can be a remote call
310 interface, but it cannot be a remote types or shared passive library unit.]}
311 @end{Ramification}
312
313 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0206-1],ARef=[AI05-0243-1],ARef=[AI05-0269-1],ARef=[AI05-0299-1]}
314 @redundant[The various categories of library units and the associated
315 restrictions are described in this @Chg{Version=[3],New=[and the following],
316 Old=[clause and its]} subclauses. The categories are
317 related hierarchically in that the library units of one category can depend
318 semantically only on library units of that category or an earlier
319 one@Chg{Version=[3],New=[ in the hierarchy],Old=[]}, except
320 that the body of a remote types or remote call interface library unit is
321 unrestricted@Chg{Version=[3],New=[, the declaration of a remote types or
322 remote call interface library unit may depend on preelaborated normal library
323 units that are mentioned only in private with clauses, and all categories can
324 depend on limited views],Old=[]}.
325
326 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1],ARef=[AI05-0269-1]}
327 @Leading@;The overall hierarchy (including declared pure) is as
328 follows@Chg{Version=[3],New=[, with a lower-numbered category being
329 @ldquote@;earlier in the hierarchy@rdquote in the sense of the
330 previous paragraph],Old=[]}:
331 @begin{Enumerate}
332 @ChgRef{Version=[3],Kind=[Added]}
333 @ChgAdded{Version=[3],Text=[Declared Pure]}
334
335 @ChgRef{Version=[3],Kind=[Added]}
336 @ChgAdded{Version=[3],Text=[Shared Passive]}
337
338 @ChgRef{Version=[3],Kind=[Added]}
339 @ChgAdded{Version=[3],Text=[Remote Types]}
340
341 @ChgRef{Version=[3],Kind=[Added]}
342 @ChgAdded{Version=[3],Text=[Remote Call Interface]}
343
344 @ChgRef{Version=[3],Kind=[Added]}
345 @ChgAdded{Version=[3],Text=[Normal (no restrictions)]}
346 @end{Enumerate}
347 @begin{NotIso}
348 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 7 through 11
349 were deleted.>}]}@Comment{This message should be
350 deleted if the paragraphs are ever renumbered.}
351 @end{NotIso}
352 @begin{Description}
353 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0243-1]}
354 @ChgDeleted{Version=[3],Text=[Declared Pure @\Can depend only on other declared
355 pure library units;]}
356
357 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0243-1]}
358 @ChgDeleted{Version=[3],Text=[Shared Passive @\Can depend only on other shared passive
359 or declared pure library units;]}
360
361 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0206-1],ARef=[AI05-0243-1]}
362 @ChgDeleted{Version=[3],Text=[Remote Types @\The declaration of the library unit can depend only
363 on other remote types library units,
364 or one of the
365 above library unit categories, or limited views,
366 or preelaborated normal library units that are mentioned
367 only in private with clauses;
368 the body of the library unit is unrestricted;]}
369
370 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0206-1],ARef=[AI05-0243-1]}
371 @ChgDeleted{Version=[3],Text=[Remote Call Interface @\The declaration of the library unit can depend only
372 on other remote call interfaces, or one
373 of the above;
374 the body of the library unit is unrestricted;]}
375
376 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0243-1]}
377 @ChgDeleted{Version=[3],Text=[Normal @\Unrestricted.]}
378 @end{Description}
379
380 Declared pure and shared passive library units are preelaborated.
381 The declaration of a remote types or remote call interface library unit
382 is required to be preelaborable.
383 ]
384
385 @end{Intro}
386
387 @begin{ImplReq}
388 @ChgRef{Version=[1],Kind=[DeletedNoDelMsg],Ref=[8652/0079],ARef=[AI95-00208-01]}
389 @ChgDeleted{Version=[1],Text=[For a given library-level type declared in
390 a preelaborated library unit or in the declaration of a remote types or remote
391 call interface library unit, the implementation shall choose the same
392 representation for the type upon each elaboration of the type's declaration for
393 different partitions of the same program.]}
394 @end{ImplReq}
395 @begin{NotIso}
396 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraph 13 was
397 deleted.>}]}@Comment{This message should be deleted if the paragraphs
398 are ever renumbered.}
399 @end{NotIso}
400
401 @begin{ImplPerm}
402
403 Implementations are allowed to define other categorization pragmas.
404
405 @end{ImplPerm}
406
407 @begin{DiffWord95}
408 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0078],ARef=[AI95-00048-01]}
409 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that a library
410 subprogram can be a remote call interface unit.]}
411
412 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0079],ARef=[AI95-00208-01]}
413 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Removed the requirement that
414 types be represented the same in all partitions, because it prevents the
415 definition of heterogeneous distributed systems and goes much further than
416 required.]}
417 @end{DiffWord95}
418
419 @begin{DiffWord2005}
420 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0206-1],ARef=[AI05-0299-1]}
421 @ChgAdded{Version=[3],Text=[We now allow private withs of preelaborated
422 units in Remote Types and Remote Call Interface units; this is documented
423 as an extension in the subclauses where this is defined normatively.]}
424
425 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1],ARef=[AI05-0299-1]}
426 @ChgAdded{Version=[3],Text=[We have introduced categorization aspects; these
427 are documented as extensions in the subclauses where they actually are defined.]}
428 @end{DiffWord2005}
429
430
431 @LabeledSubClause{Shared Passive Library Units}
432 @begin{Intro}
433 @redundant[A shared passive library unit is used for managing global data
434 shared between active partitions. The restrictions on shared passive
435 library units prevent the data or tasks of one active partition
436 from being accessible to another active partition through
437 references implicit in objects declared in the shared passive library
438 unit.]
439 @end{Intro}
440
441 @begin{MetaRules}
442 The restrictions governing a shared
443 passive library unit are
444 designed to ensure that objects and
445 subprograms declared in the package can be used safely from
446 multiple active partitions, even though the active partitions
447 live in different address spaces, and have separate run-time systems.
448 @end{MetaRules}
449
450 @begin{Syntax}
451 @begin{SyntaxText}
452 @Leading@PDefn2{Term=[categorization pragma], Sec=(Shared_Passive)}
453 @PDefn2{Term=[pragma, categorization], Sec=(Shared_Passive)}
454 The form of a @nt{pragma} Shared_Passive is as follows:
455 @end{SyntaxText}
456
457 @PragmaSyn`@key{pragma} @prag(Shared_Passive)[(@SynI{library_unit_}@Syn2{name})];'
458
459 @end{Syntax}
460
461 @begin{Legality}
462
463 @Leading@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
464 @Defn{shared passive library unit}
465 A@Chg{Version=[3],New=[ @nt{pragma} Shared_Passive is used to specify that a
466 library unit is a],Old=[]} @i{shared passive library unit}@Chg{Version=[3],New=[,
467 namely that the],Old=[ is
468 a library unit to which a]}
469 Shared_Passive
470 @Chg{Version=[3],New=[aspect@AspectDefn{Shared_Passive} of the library unit is
471 True],Old=[pragma applies]}. The following restrictions apply to such a library
472 unit:
473
474 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Shared_Passive],
475 Text=[@ChgAdded{Version=[3],Text=[A given package is used to represent
476 shared memory in a distributed system.]}]}
477
478 @begin{itemize}
479 @Redundant[it shall be preelaborable (see @RefSecNum{Elaboration Control});]
480 @begin{Ramification}
481 It cannot contain library-level declarations of protected objects
482 with entries, nor of task objects. Task objects are disallowed
483 because passive partitions don't have any threads of control of their
484 own, nor any run-time system of their own.
485 Protected objects with entries are disallowed because an entry queue
486 contains references to calling tasks, and that would require in
487 effect a pointer from a passive partition back to a task in
488 some active partition.
489 @end{Ramification}
490
491 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
492 it shall depend semantically only upon declared pure or shared passive
493 @Chg{Version=[3],New=[@nt{library_item}s],Old=[library units]};
494 @begin{Reason}
495 Shared passive packages cannot depend semantically upon remote types packages
496 because the values of an access type declared in a remote types package
497 refer to the local heap of the active partition including the
498 remote types package.
499 @end{Reason}
500 @begin{Ramification}
501 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
502 @ChgAdded{Version=[3],Text=[We say @nt{library_item} here, so that
503 limited views are allowed; those are not library units, but they are
504 @nt{library_item}.]}
505 @end{Ramification}
506
507 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0080],ARef=[AI95-00003-01]}
508 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0038-1]}
509 it shall not contain a library-level declaration of an access type
510 that designates a class-wide type,@Chg{Version=[4],New=[ nor a type
511 with a part that is of a],Old=[]}
512 task type@Chg{Version=[4],New=[],Old=[,]} or protected type with
513 @nt{entry_declaration}s@Chg{Version=[4],New=[;],Old=[@Chg{New=[],
514 Old=[; if the shared passive library unit is generic, it shall
515 not contain a declaration for such an access type unless the
516 declaration is nested within a body other than
517 a @nt<package_body>]}.]}
518 @begin{Reason}
519 These kinds of access types are disallowed because the object
520 designated by an access value of such a type could
521 contain an implicit reference back to
522 the active partition on whose behalf the designated object was
523 created.
524 @end{Reason}
525
526 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0038-1]}
527 @ChgAdded{Version=[4],Text=[it shall not contain a library-level declaration
528 that contains a name that denotes a type declared within a declared-pure
529 package, if that type has a part that is of an access type; for the purposes of
530 this rule, the parts considered include those of the full views of any private
531 types or private extensions.]}
532
533 @begin{Reason}
534 @ChgRef{Version=[4],Kind=[AddedNormal]}
535 @ChgAdded{Version=[4],Text=[This rule breaks privacy by looking into the full
536 views of private types. Avoiding privacy breakage here would have required
537 disallowing the use in a shared passive package of any private type
538 declared in a declared-pure package, which would have been severely
539 incompatible.]}
540 @end{Reason}
541
542 @end{itemize}
543
544 @PDefn2{Term=[accessibility], Sec=(from shared passive library units)}
545 @Defn{notwithstanding}
546 Notwithstanding the definition of accessibility given in
547 @RefSecNum(Operations of Access Types), the declaration
548 of a library unit P1 is not accessible from within the declarative
549 region of a shared passive library unit P2,
550 unless the shared passive library unit
551 P2 depends semantically on P1.
552 @begin{Discussion}
553 We considered a more complex rule, but dropped it. This is
554 the simplest rule that recognizes that a shared passive
555 package may outlive some other library package, unless it
556 depends semantically on that package. In a nondistributed
557 program, all library packages are presumed to have the same lifetime.
558
559 Implementations may define additional pragmas that
560 force two library packages to be in the same partition, or to have
561 the same lifetime, which would allow this rule to be relaxed
562 in the presence of such pragmas.
563 @end{Discussion}
564
565 @end{Legality}
566
567 @begin{StaticSem}
568
569 @PDefn{preelaborated}
570 A shared passive library unit is
571 preelaborated.
572
573 @end{StaticSem}
574
575 @begin{LinkTime}
576
577 A shared passive library unit shall be
578 assigned to at most one partition within a given program.
579
580 @PDefn2{Term=[compilation units needed], Sec=(shared passive library unit)}
581 @PDefn2{Term=[needed], Sec=(shared passive library unit)}
582 @Defn{notwithstanding}
583 Notwithstanding the rule given in @RefSecNum{Program Execution},
584 a compilation unit in a given partition
585 does not @i{need} (in the
586 sense of @RefSecNum{Program Execution})
587 the shared passive library units
588 on which it depends semantically to be included in that same
589 partition; they will typically reside in separate passive
590 partitions.
591
592 @end{LinkTime}
593
594 @begin{DiffWord95}
595 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0080],ARef=[AI95-00003-01]}
596 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the wording to allow
597 access types in blocks in shared passive generic packages.]}
598 @end{DiffWord95}
599
600 @begin{Extend2005}
601 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
602 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}Shared_Passive
603 is now a categorization aspect,
604 so it can be specified by an @nt{aspect_specification} @em
605 although the pragma is still preferred by the Standard.]}
606 @end{Extend2005}
607
608 @begin{Incompatible2012}
609 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0038-1]}
610 @ChgAdded{Version=[4],Text=[@Defn{incompatibilities with Ada 2012}@b<Corrigendum:>
611 Uses of access types declared in declared-pure units are not allowed in
612 library-level shared passive packages. These were allowed by Ada 2005 and
613 Ada 2012, but it is unlikely that they work properly, as active partitions
614 could disappear before the shared-passive partition. As such, the new
615 errors are more likely to catch bugs than to cause them.]}
616 @end{Incompatible2012}
617
618
619 @LabeledSubClause{Remote Types Library Units}
620
621 @begin{Intro}
622 @redundant[A remote types library unit supports the definition of types
623 intended for use in communication between active
624 partitions.]
625 @end{Intro}
626 @begin{MetaRules}
627 The restrictions governing a remote types package are similar to those for
628 a declared pure package. However, the restrictions are relaxed
629 deliberately to allow such a package to contain declarations that violate
630 the stateless property of pure packages, though it is presumed
631 that any state-dependent properties are essentially invisible
632 outside the package.
633 @end{MetaRules}
634
635 @begin{Syntax}
636 @begin{SyntaxText}
637 @Leading@PDefn2{Term=[categorization pragma], Sec=(Remote_Types)}
638 @PDefn2{Term=[pragma, categorization], Sec=(Remote_Types)}
639 The form of a @nt{pragma} Remote_Types is as follows:
640 @end{SyntaxText}
641
642 @PragmaSyn`@key{pragma} @prag(Remote_Types)[(@SynI{library_unit_}@Syn2{name})];'
643
644 @end{Syntax}
645
646 @begin{Legality}
647
648 @Leading@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
649 @Defn{remote types library unit}
650 A@Chg{Version=[3],New=[ @nt{pragma} Remote_Types is used to specify that a library unit is a],Old=[]}
651 @i{remote types library unit}@Chg{Version=[3],New=[,
652 namely that the],Old=[ is a library unit to which the pragma]}
653 Remote_Types
654 @Chg{Version=[3],New=[aspect@AspectDefn{Remote_Types} of the library unit is
655 True],Old=[applies]}. The following restrictions apply to the declaration of
656 such a library unit:
657
658 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Remote_Types],
659 Text=[@ChgAdded{Version=[3],Text=[Types in a given package may be used in
660 remote procedure calls.]}]}
661
662 @begin{itemize}
663 @Redundant[it shall be preelaborable;]
664
665 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0206-1],ARef=[AI05-0243-1]}
666 it shall depend semantically only on declared pure@Chg{Version=[3],New=[
667 @nt{library_item}s],Old=[]}, shared passive@Chg{Version=[3],New=[ library
668 units],Old=[]}, @Chg{Version=[3],New=[],Old=[or ]}other remote types library
669 units@Chg{Version=[3],New=[, or preelaborated normal library units that are
670 mentioned only in private with clauses],Old=[]};
671
672 @begin{Ramification}
673 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
674 @ChgAdded{Version=[3],Text=[We say declared pure @nt{library_item} here,
675 so that (all) limited views are allowed; those are not library units, but
676 they are declared pure @nt{library_item}s.]}
677 @end{Ramification}
678
679 it shall not contain the declaration of any variable
680 within the visible part of the library unit;
681 @begin{Reason}
682 This is essentially a @lquotes@;methodological@rquotes@; restriction.
683 A separate copy of a remote types package is included
684 in each partition that references it, just like a normal package.
685 Nevertheless, a remote types package is thought of as
686 an @lquotes@;essentially pure@rquotes@; package for defining types to be used
687 for interpartition communication,
688 and it could be misleading to declare visible objects
689 when no remote data access is actually being provided.
690 @end{Reason}
691
692
693 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00240-01],ARef=[AI95-00366-01]}
694 @Chg{Version=[2],New=[],Old=[if ]}the full view of @Chg{Version=[2],New=[each],Old=[a]}
695 type declared in the visible part of the
696 library unit @Chg{Version=[2],New=[that has any available stream attributes
697 shall support external streaming (see
698 @RefSecNum{Stream-Oriented Attributes})], Old=[has a part that is of a
699 nonremote access type, then that access type, or the type of some
700 part that includes the access type subcomponent,
701 shall have user-specified Read and Write attributes]}.
702 @begin{Reason}
703 This is to prevent the use of the predefined Read and Write
704 attributes of an access type as part of the Read and Write
705 attributes of a visible type.
706 @end{Reason}
707 @begin{Ramification}
708 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00366-01]}
709 @ChgAdded{Version=[2],Text=[Types that do not have available stream
710 attributes are excluded from this rule; that means that attributes do not
711 need to be specified for most limited types. It is only necessary to specify
712 attributes for nonlimited types that have a part that is of any access type,
713 and for extensions of limited types with available stream attributes where
714 the @nt{record_extension_part} includes a subcomponent of an access type,
715 where the access type does not have specified attributes.]}
716 @end{Ramification}
717 @end{itemize}
718
719 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0082],ARef=[AI95-00164-01]}
720 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0060-1]}
721 @ChgAdded{Version=[1],Type=[Leading],Text=[]}@ChgNote{Use ChgAdded to get conditional Leading}@Defn{remote access type}
722 @Chg{Version=[3],New=[A named],Old=[An]} access type declared in the
723 visible part of a remote types or remote
724 call interface library unit is called a @i{remote access type}.
725 @Defn{remote access-to-subprogram type}
726 @Defn{remote access-to-class-wide type}
727 Such a type shall be@Chg{New=[:],Old=[ either an access-to-subprogram type
728 or a general access type that designates a class-wide limited private
729 type.]}
730
731 @begin{Itemize}
732 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0082],ARef=[AI95-00164-01]}
733 @ChgAdded{Version=[1],Text=[an access-to-subprogram type, or]}
734
735 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0082],ARef=[AI95-00164-01]}
736 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0060-1]}
737 @ChgAdded{Version=[1],Text=[a general access type that designates a class-wide
738 limited private type@Chg{Version=[3],New=[, a class-wide limited interface
739 type,],Old=[]} or a class-wide
740 private @Chg{Version=[3],New=[],Old=[type ]}extension all of whose
741 ancestors are either
742 private @Chg{Version=[3],New=[],Old=[type ]}extensions@Chg{Version=[3],New=[,
743 limited interface types,],Old=[]} or limited private types.]}
744 @end{Itemize}
745
746 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0081],ARef=[AI95-00004-01]}
747 @ChgAdded{Version=[1],Text=[A type that is derived from a remote access type
748 is also a remote access type.]}
749
750 @Leading@;The following restrictions apply to the use of a
751 remote access-to-subprogram type:
752 @begin{Itemize}
753
754 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00431-01]}
755 A value of a remote access-to-subprogram type
756 shall be converted only to @Chg{Version=[2],New=[or from ],Old=[]}another
757 (subtype-conformant) remote access-to-subprogram type;
758
759 The @nt<prefix> of an Access @nt<attribute_reference> that yields
760 a value of a remote access-to-subprogram type shall statically denote a
761 (subtype-conformant) remote subprogram.
762 @end{Itemize}
763
764 @Leading@;The following restrictions apply to the use of a
765 remote access-to-class-wide type:
766 @begin{Itemize}
767 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0083],ARef=[AI95-00047-01]}
768 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00240-01],ARef=[AI95-00366-01]}
769 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0060-1],ARef=[AI05-0101-1]}
770 The primitive subprograms of the corresponding specific
771 @Chg{Version=[3],New=[],Old=[limited private ]}type
772 shall only have access parameters if they are controlling formal
773 parameters@Chg{Version=[3],New=[. The primitive functions of the corresponding
774 specific type shall only have an access result if it is a controlling access
775 result.],Old=[;]} @Chg{New=[@Chg{Version=[3],New=[Each],Old=[each]}
776 noncontrolling formal parameter],Old=[the types of all the noncontrolling
777 formal parameters]} @Chg{Version=[3],New=[and noncontrolling result
778 type ],Old=[]}shall @Chg{Version=[2],New=[support external streaming (see
779 @RefSecNum{Stream-Oriented Attributes});], Old=[have @Chg{New=[either a
780 nonlimited type or a type with],Old=[]} Read and Write attributes@Chg{New=[
781 specified via an @nt{attribute_definition_clause};],Old=[.]}]}
782
783 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0060-1],ARef=[AI05-0215-1],ARef=[AI05-0269-1]}
784 @ChgAdded{Version=[3],Text=[The corresponding specific type shall not have
785 a primitive procedure with the Synchronization aspect specified unless the
786 @nt{synchronization_kind} is Optional (see
787 @RefSecNum{Intertask Communication});]}
788
789 A value of a remote access-to-class-wide type shall be
790 explicitly converted only to another remote access-to-class-wide type;
791
792 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0034-1]}
793 A value of a remote access-to-class-wide type shall be dereferenced
794 (or implicitly converted to an anonymous access type)
795 only as part of a dispatching call @Chg{Version=[4],New=[to a primitive
796 operation of the designated type ],Old=[]}where the value designates
797 a controlling operand of the call (see @RefSec{Remote Subprogram Calls});
798 @begin{Ramification}
799 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0034-1]}
800 @ChgAdded{Version=[4],Text=[Stream attributes of the designated type are not
801 primitive operations of the designated type, and thus remote calls to them are
802 prohibited by this rule. This is good, as the access parameter of a stream
803 attribute does not have external streaming, and thus cannot be a parameter of
804 a remote call.]}
805 @end{Ramification}
806
807 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0101-1]}
808 @ChgAdded{Version=[3],Text=[A controlling access result value for a primitive
809 function with any controlling operands of the corresponding specific type shall
810 either be explicitly converted to a remote access-to-class-wide type or be part
811 of a dispatching call where the value designates a controlling operand of the
812 call;]}
813
814 @ChgRef{Version=[1],Kind=[Revised]}
815 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00366-01]}
816 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0085-1]}
817 The Storage_Pool @Chg{Version=[2],New=[attribute is],Old=[and
818 Storage_Size attributes are]} not defined for@Chg{Version=[2],New=[ a],Old=[]}
819 remote access-to-class-wide @Chg{Version=[2],New=[type],Old=[types]};
820 the expected type for an @nt{allocator} shall not be a remote
821 access-to-class-wide type@Chg{Version=[2],New=[. A],Old=[; a]} remote
822 access-to-class-wide type shall not be an actual parameter for a generic
823 formal access type@Chg{New=[.],Old=[;]}@Chg{Version=[2],New=[ The Storage_Size
824 attribute of a remote access-to-class-wide type yields 0@Chg{Version=[4],
825 New=[],Old=[; it is not allowed in an @nt{attribute_definition_clause}]}.],
826 Old=[]}@Chg{Version=[4],New=[ The Storage_Pool and Storage_Size aspects
827 shall not be specified for a remote access-to-class-wide type.],Old=[]}
828 @begin{Reason}
829 @ChgRef{Version=[2],Kind=[Revised]}
830 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
831 All @Chg{Version=[3],New=[],Old=[three ]}@ChgNote{There are more than three!}of
832 these restrictions are because
833 there is no storage pool associated with a remote
834 access-to-class-wide type.@Chg{Version=[2],New=[ The Storage_Size is defined
835 to be 0 so that there is no conflict with the rules for pure units.],Old=[]}
836 @end{Reason}
837 @begin{Ramification}
838 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0085-1]}
839 @ChgAdded{Version=[4],Text=[The prohibition against specifying the
840 Storage_Size aspect for an access-to-class-wide type applies to any
841 method of doing that, including via either a @nt{aspect_specification} or
842 an @nt{attribute_definition_clause}.]}
843 @end{Ramification}
844 @end{Itemize}
845
846 @end{Legality}
847
848 @begin{Erron}
849 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0076-1]}
850 @ChgAdded{Version=[4],Text=[Execution is erroneous if some operation (other
851 than the initialization or finalization of the object) modifies the value of a
852 constant object declared in the visible part of a remote types package.]}
853
854 @begin{Discussion}
855 @ChgRef{Version=[4],Kind=[AddedNormal]}
856 @ChgAdded{Version=[4],Text=[This could be accomplished via a
857 self-referencing pointer or via squirrelling a writable pointer to a
858 controlled object.]}
859 @end{Discussion}
860 @end{Erron}
861
862 @begin{Notes}
863 A remote types library unit
864 need not be pure, and the types it defines may
865 include levels of indirection implemented by using access types.
866 User-specified Read and Write attributes
867 (see @RefSecNum{Stream-Oriented Attributes})
868 provide for sending values of such a type
869 between active partitions, with Write marshalling the
870 representation, and Read unmarshalling any levels of
871 indirection.
872
873 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0060-1]}
874 @ChgAdded{Version=[3],Text=[The value of a remote access-to-class-wide limited
875 interface can designate an object of a nonlimited type derived from the
876 interface.]}
877
878 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0060-1]}
879 @ChgAdded{Version=[3],Text=[A remote access type may designate a class-wide
880 synchronized, protected, or task interface type.]}
881 @begin{TheProof}
882 @ChgRef{Version=[3],Kind=[AddedNormal]}
883 @ChgAdded{Version=[3],Text=[Synchronized, protected, and task interfaces
884 are all considered limited interfaces, see @RefSecNum{Interface types}.]}
885 @end{TheProof}
886
887 @end{Notes}
888
889 @begin{Incompatible95}
890 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00240-01]}
891 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0248-1]}
892 @ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
893 @b[Amendment Correction:] The wording was changed from
894 @lquotes@;user-specified@rquotes to @lquotes@;available@rquotes
895 @Chg{Version=[3],New=[read and write ],Old=[]}attributes. (This was then
896 further changed, see below.) This means that
897 an access type with the attributes specified in the private part would
898 originally have been sufficient to allow the access type to be used in
899 a remote type, but that is no longer allowed. Similarly, the attributes
900 of a remote type that has access components have to be specified in the
901 visible part. These changes were made so that the rules were consistent with
902 the rules introduced for the Corrigendum for stream attributes; moreover,
903 legality should not depend on the contents of the private part.]}
904 @end{Incompatible95}
905
906 @begin{Extend95}
907 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00366-01]}
908 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
909 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
910 Remote types that cannot be streamed (that is, have no available stream
911 attributes) do not require the specification of stream attributes.
912 This is necessary so that most extensions of Limited_Controlled do not
913 need stream attributes defined (otherwise there would be a
914 @Chg{Version=[3],New=[significant],Old=[signficant]}
915 incompatibility, as Limited_Controlled would need stream attributes, and then
916 all extensions of it also would need stream attributes).]}
917 @end{Extend95}
918
919 @begin{DiffWord95}
920 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0081],ARef=[AI95-00004-01]}
921 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Added missing wording so that
922 a type derived from a remote access type is also a remote access type.]}
923
924 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0083],ARef=[AI95-00047-01]}
925 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that user-defined
926 Read and Write attributes are required for the primitive subprograms
927 corresponding to a remote access-to-class-wide type.]}
928
929 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0082],ARef=[AI95-00164-01]}
930 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Added missing wording so that
931 a remote access type can designate an appropriate private extension.]}
932
933 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00366-01]}
934 @ChgAdded{Version=[2],Text=[Changed the wording to use the newly defined
935 term @i<type that supports external streaming>, so that various issues
936 with access types in pure units and implicitly declared attributes for
937 type extensions are properly handled.]}
938
939 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00366-01]}
940 @ChgAdded{Version=[2],Text=[Defined Storage_Size to be 0 for
941 remote access-to-class-wide types, rather than having it undefined. This
942 eliminates issues with pure units requiring a defined storage size.]}
943
944 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00431-01]}
945 @ChgAdded{Version=[2],Text=[Corrected the wording so that a value of a local
946 access-to-subprogram type cannot be converted to a remote
947 access-to-subprogram type, as intended (and required by the ACATS).]}
948 @end{DiffWord95}
949
950 @begin{Incompatible2005}
951 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0101-1]}
952 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0005-1]}
953 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}@b<Correction:>
954 Added rules for returning of remote
955 @Chg{Version=[4],New=[access-to-class-wide],Old=[access-to-classwide]} types;
956 this had been missed in the past. While programs that returned unstreamable
957 types from RCI
958 functions were legal, it is not clear what they could have done (as the
959 results could not be marshalled). Similarly, RCI functions that return remote
960 controlling access types could try to save those values, but it is unlikely
961 that a compiler would know how to do that usefully. Thus, it seems unlikely
962 that any real programs will be impacted by these changes.]}
963 @end{Incompatible2005}
964
965 @begin{Extend2005}
966 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0060-1]}
967 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}@b<Correction:>
968 Clarified that anonymous access types are never remote access types (and can
969 be used in remote types units subject to the normal restrictions). Added
970 wording to allow limited class-wide interfaces to be designated by remote
971 access types.]}
972
973 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0206-1]}
974 @ChgAdded{Version=[3],Text=[Added wording to allow private withs of
975 preelaborated normal units in the specification of a remote types unit.]}
976
977 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
978 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}Remote_Types
979 is now a categorization aspect,
980 so it can be specified by an @nt{aspect_specification} @em
981 although the pragma is still preferred by the Standard.]}
982 @end{Extend2005}
983
984 @begin{DiffWord2012}
985 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0034-1]}
986 @ChgAdded{Version=[4],Text=[@B<Corrigendum:> Clarified that dispatching
987 remote stream attribute calls are prohibited. We don't document this as
988 an incompatibility, as the stream parameter cannot be marshalled for a
989 remote call (it doesn't have external streaming), so it's impossible that
990 any working program depends on this functionality.]}
991
992 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0076-1]}
993 @ChgAdded{Version=[4],Text=[@B<Corrigendum:> Explicitly stated that modifying
994 a visible constant in a remote types package is erroneous. We don't document
995 this as inconsistent as implementations certainly can still do whatever they
996 were previously doing (no change is required); moreover, this case (and many
997 more) were erroneous in Ada 2005 and before, so we're just restoring the
998 previous semantics.]}
999
1000 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0085-1]}
1001 @ChgAdded{Version=[4],Text=[@B<Corrigendum:> Clarified that specifying
1002 the Storage_Pool or Storage_Size aspect for an access-to-class-wide type is
1003 not allowed. The intent is clear, and no implementation has ever allowed
1004 specifying the aspects (the attributes already cannot be specified),
1005 so we don't document this as an incompatibility.]}
1006 @end{DiffWord2012}
1007
1008
1009 @LabeledSubClause{Remote Call Interface Library Units}
1010
1011 @begin{Intro}
1012 @redundant[A remote call interface library unit can be
1013 used as an interface for remote procedure calls (RPCs) (or remote
1014 function calls) between active partitions.]
1015 @end{Intro}
1016
1017 @begin{MetaRules}
1018 The restrictions governing a remote call
1019 interface library unit are intended to ensure that
1020 the values of the actual parameters in a remote call can be meaningfully
1021 sent between two active partitions.
1022 @end{MetaRules}
1023
1024 @begin{Syntax}
1025 @begin{SyntaxText}
1026 @Leading@PDefn2{Term=[categorization pragma], Sec=(Remote_Call_Interface)}
1027 @PDefn2{Term=[pragma, categorization], Sec=(Remote_Call_Interface)}
1028 The form of a @nt{pragma} Remote_Call_Interface is as follows:
1029 @end{SyntaxText}
1030
1031 @PragmaSyn`@key{pragma} @prag(Remote_Call_Interface)[(@SynI{library_unit_}@Syn2{name})];'
1032
1033 @begin{SyntaxText}
1034 @Leading@;The form of a @nt{pragma} All_Calls_Remote is as follows:
1035 @end{SyntaxText}
1036
1037 @PragmaSyn`@key{pragma} @prag(All_Calls_Remote)[(@SynI{library_unit_}@Syn2{name})];'
1038
1039 @begin{SyntaxText}
1040 @PDefn2{Term=[library unit pragma], Sec=(All_Calls_Remote)}
1041 @PDefn2{Term=[pragma, library unit], Sec=(All_Calls_Remote)}
1042 A @nt{pragma} All_Calls_Remote is a library unit pragma.
1043 @end{SyntaxText}
1044
1045 @end{Syntax}
1046
1047 @begin{Legality}
1048
1049 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1050 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
1051 @Defn{remote call interface}
1052 @Defn2{Term=[RCI],Sec=(library unit)}
1053 @Defn2{Term=[RCI],Sec=(package)}
1054 @Defn2{Term=[RCI],Sec=(generic)}
1055 @Defn{remote subprogram}
1056 A@Chg{Version=[3],New=[ @nt{pragma} Remote_Call_Interface is used to specify that a
1057 library unit is a],Old=[]} @i{remote call interface (RCI)}@Chg{Version=[3],New=[,
1058 namely that the],Old=[ is a library unit to which the pragma]}
1059 Remote_Call_Interface
1060 @Chg{Version=[3],New=[aspect@AspectDefn{Remote_Call_Interface} of the library
1061 unit is True],Old=[applies]}. A subprogram declared in the visible part of such
1062 a library unit@Chg{New=[, or declared by such a library unit,],Old=[]} is called
1063 a @i{remote subprogram}.
1064
1065 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Remote_Call_Interface],
1066 Text=[@ChgAdded{Version=[3],Text=[Subprograms in a given package may be
1067 used in remote procedure calls.]}]}
1068
1069 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0206-1],ARef=[AI05-0243-1]}
1070 The declaration of an RCI library unit shall be preelaborable
1071 (see @RefSecNum{Elaboration Control}), and shall depend semantically
1072 only upon declared pure@Chg{Version=[3],New=[ @nt{library_item}s],Old=[]},
1073 shared passive@Chg{Version=[3],New=[ library units],Old=[]},
1074 remote types@Chg{Version=[3],New=[ library units],Old=[]},
1075 @Chg{Version=[3],New=[],Old=[or ]}other remote call interface library
1076 units@Chg{Version=[3],New=[, or preelaborated normal library units that are
1077 mentioned only in private with clauses],Old=[]}.
1078
1079 @begin{Ramification}
1080 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
1081 @ChgAdded{Version=[3],Text=[We say declared pure @nt{library_item} here,
1082 so that (all) limited views are allowed; those are not library units, but
1083 they are declared pure @nt{library_item}s.]}
1084 @end{Ramification}
1085
1086 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1087 @Leading@;In addition, the following restrictions apply to @Chg{New=[],Old=[the
1088 visible part of ]}an RCI library unit:
1089 @begin{itemize}
1090 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1091 it@Chg{New=[s visible part],Old=[]} shall not contain the declaration of a
1092 variable;
1093 @begin{Reason}
1094 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1095 Remote call interface @Chg{New=[units],Old=[packages]} do not provide remote
1096 data access. A shared passive package has to be used for that.
1097 @end{Reason}
1098
1099 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1100 it@Chg{New=[s visible part],Old=[]} shall not contain the declaration of a
1101 limited type;
1102 @begin{Reason}
1103 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00240-01],ARef=[AI95-00366-01]}
1104 We disallow the declaration of task and protected types,
1105 since calling an entry or a protected subprogram implicitly passes
1106 an object of a limited type (the target task or protected object).
1107 We disallow other limited types since we require that such types
1108 have @Chg{Version=[2],New=[available],Old=[user-defined]} Read and Write
1109 attributes, but we certainly
1110 don't want the Read and Write attributes themselves to involve remote
1111 calls (thereby defeating their purpose of marshalling the
1112 value for remote calls).
1113 @end{Reason}
1114
1115 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1116 it@Chg{New=[s visible part],Old=[]} shall not contain a nested
1117 @nt{generic_declaration};
1118 @begin{Reason}
1119 This is disallowed because the body of the nested generic
1120 would presumably have access to data inside the body of the
1121 RCI package, and if instantiated in a different partition, remote
1122 data access might result, which is not supported.
1123 @end{Reason}
1124
1125 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1126 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1127 it shall not @Chg{New=[be, nor shall its visible part],Old=[]} contain@Chg{New=[,],Old=[]} the
1128 declaration of a subprogram @Chg{Version=[3],New=[for],Old=[to]} which
1129 @Chg{Version=[3],New=[aspect],Old=[a pragma]} Inline @Chg{Version=[3],New=[is True],
1130 Old=[applies]};
1131
1132 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1133 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00240-01],ARef=[AI95-00366-01]}
1134 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0101-1]}
1135 it shall not @Chg{New=[be, nor shall its visible part],
1136 Old=[]} contain@Chg{New=[,],Old=[]} a
1137 subprogram (or access-to-subprogram) declaration
1138 whose profile has @Chg{Version=[2],New=[@Chg{Version=[3],New=[],
1139 Old=[@Redundant[an access parameter or]]}
1140 a parameter @Chg{Version=[3],New=[or result ],Old=[]}of a type that
1141 does not support external streaming
1142 (see @RefSecNum{Stream-Oriented Attributes})],
1143 Old=[an access parameter, or a formal parameter of a
1144 limited type unless that limited type has user-specified Read and Write
1145 attributes]};
1146
1147 @begin{Ramification}
1148 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0101-1]}
1149 @ChgAdded{Version=[3],Text=[No anonymous access types support external
1150 streaming, so they are never allowed as parameters or results of
1151 RCI subprograms.]}
1152 @end{Ramification}
1153
1154 any public child of the library unit shall
1155 be a remote call interface library unit.
1156 @begin{Reason}
1157 No restrictions apply to the private part of an RCI package,
1158 and since a public child can @lquotes@;see@rquotes@; the private part
1159 of its parent, such a child must itself have a
1160 Remote_Call_Interface pragma, and be assigned to the same partition
1161 (see below).
1162 @end{Reason}
1163 @begin{Discussion}
1164 We considered making the public child of an RCI package
1165 implicitly RCI, but it seemed better to require an explicit
1166 pragma to avoid any confusion.
1167
1168 Note that there is no need for a private child to be an RCI package,
1169 since it can only be seen from the body of its parent
1170 or its siblings, all of which are required to be in the
1171 same active partition.
1172 @end{Discussion}
1173 @end{itemize}
1174
1175 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1176 @Chg{Version=[3],New=[A],Old=[If a]} pragma All_Calls_Remote
1177 @Chg{Version=[3],New=[sets the All_Calls_Remote representation aspect of
1178 @AspectDefn{All_Calls_Remote}the],Old=[applies to a]} library unit@Chg{Version=[3],New=[ to which the pragma
1179 applies to the value True. If the All_Calls_Remote aspect of a library unit is True],
1180 Old=[]}, the library unit shall be a remote call interface.
1181
1182 @ChgAspectDesc{Version=[4],Kind=[Revised],InitialVersion=[3],Aspect=[All_Calls_Remote],
1183 Text=[@ChgAdded{Version=[3],Text=[All @Chg{Version=[4],New=[indirect or
1184 dispatching remote subprogram calls and all direct],Old=[]}
1185 remote @Chg{Version=[4],New=[subprogram],Old=[procedure]} calls
1186 should use the Partition Communication
1187 Subsystem@Chg{Version=[4],New=[],Old=[, even if they are local]}.]}]}
1188
1189 @end{Legality}
1190
1191 @begin{LinkTime}
1192
1193 A remote call interface library unit shall be
1194 assigned to at most one partition of a given program.
1195 A remote call
1196 interface library unit whose parent is also an RCI library unit
1197 shall be
1198 assigned only to the same partition as its parent.
1199 @begin{ImplNote}
1200 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1201 The declaration of an RCI @Chg{New=[unit],Old=[package]}, with a calling-stub
1202 body, is automatically included in all active
1203 partitions with compilation units that depend on it.
1204 However the whole RCI library unit, including its
1205 (non-stub) body, will only be in one of the active partitions.
1206 @end{ImplNote}
1207
1208 @PDefn2{Term=[compilation units needed], Sec=(remote call interface)}
1209 @PDefn2{Term=[needed], Sec=(remote call interface)}
1210 @Defn{notwithstanding}
1211 Notwithstanding the rule given in @RefSecNum{Program Execution},
1212 a compilation unit in a given partition that semantically depends on
1213 the declaration of an RCI library unit,
1214 @i{needs} (in the sense of @RefSecNum{Program Execution})
1215 only the declaration of the
1216 RCI library unit, not the body, to be included in that same partition.
1217 @Redundant[Therefore, the body of an RCI library unit is included
1218 only in the partition to which the RCI library unit is
1219 explicitly assigned.]
1220
1221 @end{LinkTime}
1222
1223 @begin{ImplReq}
1224 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1225 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1226 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0031-1]}
1227 @ChgNote{Use ChgAdded to get conditional Leading}@ChgAdded{Version=[4],
1228 Type=[Leading],Text=[]}If @Chg{Version=[3],New=[aspect],Old=[a pragma]}
1229 All_Calls_Remote @Chg{Version=[3],New=[is True for],Old=[applies to]} a
1230 given RCI library @Chg{New=[unit],Old=[package]}, then the
1231 implementation shall route any @Chg{Version=[4],New=[of the following calls],
1232 Old=[call to a subprogram of the RCI @Chg{New=[unit],Old=[package]} from
1233 outside the declarative region of the @Chg{New=[unit],Old=[package]}]} through
1234 the Partition Communication Subsystem (PCS); see
1235 @RefSecNum{Partition Communication Subsystem}@Chg{Version=[4],New=[:],Old=[.
1236 Calls to such subprograms from within the declarative region of
1237 the @Chg{New=[unit],Old=[package]} are defined to be local and shall
1238 not go through the PCS.]}
1239 @begin{Itemize}
1240 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0031-1]}
1241 @ChgAdded{Version=[4],Text=[A direct call to a subprogram of the RCI unit from
1242 outside the declarative region of the unit;]}
1243
1244 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0031-1]}
1245 @ChgAdded{Version=[4],Text=[An indirect call through a remote
1246 access-to-subprogram value that designates a subprogram of the RCI unit;]}
1247
1248 @ChgRef{Version=[4],Kind=[Added],ARef=[AI12-0031-1]}
1249 @ChgAdded{Version=[4],Text=[A dispatching call with a controlling operand
1250 designated by a remote access-to-class-wide value whose tag identifies a
1251 type declared in the RCI unit.]}
1252 @end{Itemize}
1253 @begin{Discussion}
1254 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0078],ARef=[AI95-00048-01]}
1255 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1256 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0031-1]}
1257 @Chg{Version=[3],New=[When this aspect is False (or not used)],Old=[Without
1258 this pragma]}, it is presumed
1259 that most implementations will@Chg{Version=[4],New=[ not],Old=[]}
1260 make@Chg{Version=[4],New=[],Old=[ direct]} calls@Chg{Version=[4],New=[ through
1261 the PCS],Old=[]} if the call originates in the same partition
1262 as that of the RCI @Chg{New=[unit],Old=[package]}. @Chg{Version=[3],New=[When
1263 this aspect is True],Old=[With this pragma]}, all @Chg{Version=[4],New=[indirect
1264 or dispatching remote subprogram calls to the RCI unit and all
1265 direct ],Old=[]}calls
1266 from outside the subsystem rooted at the RCI @Chg{New=[unit],Old=[package]} are
1267 treated like calls from outside the
1268 partition, ensuring that the PCS is involved in all such calls
1269 (for debugging, redundancy, etc.).
1270 @end{Discussion}
1271 @begin{Reason}
1272 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0031-1]}
1273 There is no point to force local @Chg{Version=[4],New=[direct ],Old=[]}calls
1274 (@Chg{Version=[4],New=[including],Old=[or]} calls from children) to go through
1275 the PCS, since on the target system@Chg{Version=[4],New=[],Old=[,]} these calls
1276 are always local, and all the units are in the same active partition.
1277 @end{Reason}
1278 @end{ImplReq}
1279
1280 @begin{ImplPerm}
1281
1282 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0243-1]}
1283 An implementation need not support the
1284 Remote_Call_Interface pragma @Chg{Version=[3],New=[or aspect ],Old=[]}nor
1285 the All_Calls_Remote pragma.
1286 @Redundant[Explicit message-based communication between active partitions can
1287 be supported as an alternative to RPC.]
1288 @begin{Ramification}
1289 Of course, it is pointless to support the All_Calls_Remote
1290 pragma if the Remote_Call_Interface pragma (or some
1291 approximate equivalent) is not supported.
1292 @end{Ramification}
1293
1294 @end{ImplPerm}
1295
1296 @begin{Incompatible95}
1297 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00240-01]}
1298 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0248-1]}
1299 @ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
1300 @b[Amendment Correction:] The wording was changed from
1301 @lquotes@;user-specified@rquotes to @lquotes@;available@rquotes
1302 @Chg{Version=[3],New=[read and write ],Old=[]}attributes. (This was then
1303 further changed, see below.) This means that
1304 a type with the attributes specified in the private part would
1305 originally have been allowed as a formal parameter of an RCI subprogram,
1306 but that is no longer allowed.
1307 This change was made so that the rules were consistent with the rules
1308 introduced for the Corrigendum for stream attributes; moreover, legality
1309 should not depend on the contents of the private part.]}
1310 @end{Incompatible95}
1311
1312 @begin{DiffWord95}
1313 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0078],ARef=[AI95-00048-01]}
1314 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Changed the wording to allow
1315 a library subprogram to be a remote call interface unit.]}
1316
1317 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00366-01]}
1318 @ChgAdded{Version=[2],Text=[Changed the wording to use the newly defined
1319 term @i<type that supports external streaming>, so that various issues
1320 with access types in pure units and implicitly declared attributes for
1321 type extensions are properly handled.]}
1322 @end{DiffWord95}
1323
1324 @begin{Incompatible2005}
1325 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0101-1]}
1326 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}@b<Correction:>
1327 Added a rule to ensure that function results are streamable; this was
1328 missing in previous versions of Ada. While programs that returned
1329 unstreamable types from RCI functions were legal, it is not clear what
1330 they could have done (as the results could not be marshalled). Thus, it seems
1331 unlikely that any real programs will be impacted by this change.]}
1332 @end{Incompatible2005}
1333
1334 @begin{Extend2005}
1335 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0206-1]}
1336 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}Added wording to
1337 allow private withs of preelaborated normal units in the specification of a
1338 remote call interface unit.]}
1339
1340 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
1341 @ChgAdded{Version=[3],Text=[All_Calls_Remote
1342 is now a representation aspect, so it can be specified by
1343 an @nt{aspect_specification} @em
1344 although the pragma is still preferred by the Standard.]}
1345
1346 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0243-1]}
1347 @ChgAdded{Version=[3],Text=[Remote_Call_Interface
1348 is now a categorization aspect, so it can be specified by
1349 an @nt{aspect_specification} @em
1350 although the pragma is still preferred by the Standard.]}
1351 @end{Extend2005}
1352
1353 @begin{Inconsistent2012}
1354 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0031-1]}
1355 @ChgAdded{Version=[4],Text=[@Defn{incompatibilities with Ada 2012}@b<Corrigendum:>
1356 Redefined when indirect and dispatching remote calls have to be remote
1357 for a unit for which the aspect All_Calls_Remote is True. With the new rules,
1358 a local target called indirectly or via dispatching will be routed through
1359 the PCS, while that was not necessarily true in earlier Ada. If a program
1360 depended on local targets not being routed through the PCS even when
1361 All_Calls_Remote is used, then it might behave differently or fail in
1362 corrected Ada 2012. This is highly unlikely as PCS is going to be able to
1363 communicate with any partition of the program, including the local partition.]}
1364 @end{Inconsistent2012}
1365
1366
1367 @LabeledClause{Consistency of a Distributed System}
1368
1369 @begin{Intro}
1370 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
1371 @redundant[This @Chg{Version=[3],New=[subclause],Old=[clause]} defines
1372 attributes and rules associated with verifying
1373 the consistency of a distributed program.]
1374 @end{Intro}
1375
1376 @begin{MetaRules}
1377
1378 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0248-1]}
1379 The rules guarantee that remote call interface
1380 and shared passive @Chg{Version=[3],New=[library units],Old=[packages]}
1381 are consistent among all partitions
1382 prior to the execution of a distributed program, so
1383 that the semantics of the distributed program are well defined.
1384
1385 @end{MetaRules}
1386
1387 @begin{StaticSem}
1388
1389 @ChgRef{Version=[1],Kind=[Revised]}@ChgNote{To be consistent with 8652/0006}
1390 @Leading@;For @ChgPrefixType{Version=[1],Kind=[Revised],Text=[a
1391 @Chg{New=[@nt{prefix}],Old=[prefix]} P that statically denotes a
1392 program unit]}, the following attributes are defined:
1393 @begin{Description}
1394 @Attribute{Prefix=<P>, AttrName=<Version>,
1395 Text=[Yields a value of the predefined type String
1396 that identifies the version of the compilation unit that
1397 contains the declaration of the program unit.]}
1398
1399 @Attribute{Prefix=<P>, AttrName=<Body_Version>,
1400 Text=[Yields a value of the predefined type String
1401 that identifies the version of the compilation unit that contains
1402 the body (but not any subunits) of the program unit.]}
1403 @end{Description}
1404 @EndPrefixType{}
1405
1406 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0084],ARef=[AI95-00104-01]}
1407 @Defn2{Term=[version], Sec=(of a compilation unit)}
1408 The @i{version} of a compilation unit changes whenever the
1409 @Chg{New=[],Old=[version changes for any ]}compilation unit
1410 @Chg{New=[changes in a semantically significant way. This International
1411 Standard does not define the exact meaning of "semantically significant"],
1412 Old=[on which it depends semantically. The version also changes whenever the
1413 compilation unit itself changes in a semantically significant way]}.
1414 It is @Chg{New=[unspecified],Old=[implementation defined]}
1415 whether there are other events (such as recompilation) that
1416 result in the version of a compilation unit changing.
1417 @Chg{New=[@PDefn{unspecified}],Old=[]}
1418 @ChgImplDef{Version=[1],Kind=[Deleted],InitialVersion=[0],
1419 Text=[@Chg{New=[],Old=[Events that
1420 cause the version of a compilation unit to change.]}]}
1421
1422 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0084],ARef=[AI95-00104-01]}
1423 @ChgAdded{Version=[1],Text=[If P is not a library unit, and P has no completion,
1424 then P'Body_Version returns the Body_Version of the innermost program unit
1425 enclosing the declaration of P. If P is a library unit, and P has no
1426 completion, then P'Body_Version returns a value that is different from
1427 Body_Version of any version of P that has a completion.]}
1428 @end{StaticSem}
1429
1430 @begin{Bounded}
1431 @PDefn2{Term=(bounded error),Sec=(cause)}
1432 @Defn{unit consistency}
1433 In a distributed program, a library unit is @i{consistent} if the same
1434 version of its declaration is used throughout.
1435 It is a bounded error to elaborate a partition of a distributed
1436 program that contains a compilation unit that depends on a different
1437 version of the declaration of a shared passive or RCI library
1438 unit than
1439 that included in the partition to which the shared passive or
1440 RCI library unit
1441 was assigned.
1442 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
1443 As a result of this error, Program_Error
1444 can be raised in one or both partitions during elaboration;
1445 in any case, the partitions
1446 become inaccessible to one another.
1447 @begin{Ramification}
1448 Because a version changes if anything on which it depends undergoes
1449 a version change, requiring consistency for shared passive
1450 and remote call interface library units is
1451 sufficient to ensure
1452 consistency for the declared pure and remote types library
1453 units that
1454 define the types used for the objects and parameters
1455 through which interpartition communication takes place.
1456
1457 Note that we do not require matching Body_Versions; it is
1458 irrelevant for shared passive and remote call interface
1459 packages, since only one copy of their body exists in a
1460 distributed program (in the absence of implicit replication),
1461 and we allow the bodies to differ for declared pure and
1462 remote types packages from partition to partition, presuming
1463 that the differences are due to required error corrections
1464 that took place during the execution of a long-running distributed
1465 program. The Body_Version attribute provides a means
1466 for performing stricter consistency checks.
1467 @end{Ramification}
1468 @end{Bounded}
1469
1470 @begin{DiffWord95}
1471 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0084],ARef=[AI95-00104-01]}
1472 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified the meaning of
1473 'Version and 'Body_Version.]}
1474 @end{DiffWord95}
1475
1476
1477 @LabeledClause{Remote Subprogram Calls}
1478
1479 @begin{Intro}
1480 @Defn{remote subprogram call}
1481 @RootDefn{asynchronous remote procedure call}
1482 @Defn{calling partition}
1483 @Defn{called partition}
1484 @Defn{remote subprogram binding}
1485 A @i{remote subprogram call} is a subprogram call that invokes the
1486 execution of a subprogram in another partition.
1487 The partition that
1488 originates the remote subprogram call is the @i{calling partition}, and the
1489 partition that executes the corresponding subprogram body is the @i{called
1490 partition}.
1491 Some remote procedure calls are allowed to return prior to the completion of
1492 subprogram execution. These are called @i{asynchronous remote procedure
1493 calls}.
1494
1495 @Leading@;There are three different ways of performing a remote subprogram call:
1496 @begin{Itemize}
1497 As a direct call on a (remote) subprogram explicitly declared in a
1498 remote call interface;
1499
1500 As an indirect call through a value of a remote access-to-subprogram type;
1501
1502 As a dispatching call with a controlling operand designated by
1503 a value of a remote access-to-class-wide type.
1504 @end{Itemize}
1505
1506 The first way of calling corresponds to a @i(static) binding between
1507 the calling and the called partition.
1508 The latter two ways correspond to a @i(dynamic) binding between
1509 the calling and the called partition.
1510
1511 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0101-1]}
1512 @Chg{Version=[3],New=[Remote types library units (see
1513 @RefSecNum{Remote Types Library Units}) and],Old=[A]} remote
1514 call interface library @Chg{Version=[3],New=[units],Old=[unit]}
1515 (see @RefSecNum{Remote Call Interface Library Units})
1516 @Chg{Version=[3],New=[define],Old=[defines]}
1517 the remote subprograms or remote access types used for
1518 remote subprogram calls.
1519 @end{Intro}
1520
1521 @begin{MetaRules}
1522
1523 Remote subprogram calls are standardized since the RPC paradigm is
1524 widely-used, and establishing an interface to it in the annex will
1525 increase the portability and reusability of distributed
1526 programs.
1527
1528 @end{MetaRules}
1529
1530 @begin{Legality}
1531 In a dispatching call with two or more controlling operands,
1532 if one controlling operand is designated by a value of a
1533 remote access-to-class-wide type, then all shall be.
1534 @end{Legality}
1535
1536 @begin{RunTime}
1537
1538 @Defn{marshalling}
1539 @Defn{unmarshalling}
1540 @PDefn2{Term=[execution], Sec=(remote subprogram call)}
1541 For the execution of a remote subprogram call, subprogram parameters
1542 (and later the results, if any) are passed using a stream-oriented
1543 representation
1544 (see @RefSecNum{The Package Streams}) @Redundant[which is
1545 suitable for transmission between partitions]. This action is called
1546 @i{marshalling}. @i{Unmarshalling} is the reverse action of
1547 reconstructing the parameters or results from the stream-oriented
1548 representation.
1549 @redundant[Marshalling is performed initially as part of the remote subprogram call in
1550 the calling partition; unmarshalling is done in the called partition.
1551 After the remote subprogram completes, marshalling is performed in the
1552 called partition, and finally unmarshalling is done in the calling
1553 partition.]
1554
1555 @Defn{calling stub}
1556 @Defn{receiving stub}
1557 A @i{calling stub} is the sequence of code that replaces the subprogram
1558 body of a remotely called subprogram in the calling partition. A
1559 @i{receiving stub} is the sequence of code (the @lquotes@;wrapper@rquotes@;) that
1560 receives a remote subprogram call on the called partition and invokes
1561 the appropriate subprogram body.
1562 @begin{Discussion}
1563 The use of the term @i{stub} in this annex should not be confused with
1564 @nt{body_stub} as defined in @RefSecNum{Subunits of Compilation Units}. The
1565 term @i{stub} is used here because it is a commonly understood term when
1566 talking about the RPC paradigm.
1567 @end{Discussion}
1568
1569 @Defn{at-most-once execution}
1570 Remote subprogram calls are executed at most once, that is,
1571 if the subprogram call returns normally, then the called
1572 subprogram's body was executed exactly once.
1573
1574 The task executing a remote subprogram call blocks until the subprogram
1575 in the called partition returns, unless the call is asynchronous. For an
1576 asynchronous remote procedure call, the calling task can
1577 become ready before the
1578 procedure in the called partition returns.
1579
1580 @Defn{cancellation of a remote subprogram call}
1581 If a construct containing a remote call is aborted, the
1582 remote subprogram call is @i{cancelled}.
1583 Whether the execution of the remote subprogram is immediately aborted
1584 as a result of the cancellation is implemen@!tation defined.
1585 @ImplDef{Whether the execution of the remote subprogram is immediately
1586 aborted as a result of cancellation.}
1587
1588 If a remote subprogram call is received by a called partition before the
1589 partition has
1590 completed its elaboration, the call is kept pending until the called
1591 partition completes its elaboration (unless the call is
1592 cancelled by the calling partition prior to that).
1593
1594 If an exception is propagated by a remotely called subprogram,
1595 and the call is not an asynchronous call,
1596 the corresponding exception is reraised at the point
1597 of the remote subprogram call.
1598 For an asynchronous call, if the remote procedure call returns prior to
1599 the completion of the remotely called subprogram, any exception is lost.
1600
1601 The exception Communication_Error
1602 (see @RefSecNum{Partition Communication Subsystem}) is raised if a remote call
1603 cannot be completed due to difficulties in communicating with the called
1604 partition.
1605
1606 @PDefn2{Term=[potentially blocking operation],Sec=(remote subprogram call)}
1607 @PDefn2{Term=[blocking, potentially],Sec=(remote subprogram call)}
1608 All forms of remote subprogram calls are potentially blocking operations
1609 (see @RefSecNum{Protected Subprograms and Protected Actions}).
1610 @begin{Reason}
1611 Asynchronous remote procedure calls are potentially blocking since the
1612 implementation may require waiting for the availability of shared resources
1613 to initiate the remote call.
1614 @end{Reason}
1615
1616 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0085],ARef=[AI95-00215-01]}
1617 @IndexCheck{Accessibility_Check}
1618 In a remote subprogram call with a formal parameter of a class-wide
1619 type, a check is made that the tag of the actual parameter identifies
1620 a tagged type declared in a declared-pure or shared passive library
1621 unit, or in the visible part of a remote types or remote call interface
1622 library unit.
1623 @Defn2{Term=[Program_Error],Sec=(raised by failure of run-time check)}
1624 Program_Error is raised if this check fails.
1625 @Chg{New=[In a remote function call which returns a class-wide type, the same
1626 check is made on the function result.],Old=[]}
1627 @begin{Discussion}
1628 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0085],ARef=[AI95-00215-01]}
1629 This check makes certain that the specific type passed@Chg{New=[ or returned],
1630 Old=[]} in an RPC
1631 satisfies the rules for a "communicable" type. Normally this
1632 is guaranteed by the compile-time restrictions on remote call interfaces.
1633 However, with class-wide types, it is possible to pass an object
1634 whose tag identifies a type declared outside the "safe" packages.
1635
1636 This is considered an accessibility_check since only the types
1637 declared in "safe" packages are considered truly "global" (cross-partition).
1638 Other types are local to a single partition. This is analogous
1639 to the "accessibility" of global vs. local declarations in
1640 a single-partition program.
1641
1642 This rule replaces a rule from an early version of Ada 9X
1643 which was given in the subclause on Remote Types Library Units
1644 (now @RefSec{Remote Types Library Units}). That rule tried
1645 to prevent "bad" types from being sent by arranging for their
1646 tags to mismatch between partitions. However, that interfered
1647 with other uses of tags. The new rule allows tags to agree
1648 in all partitions, even for those types which are not "safe"
1649 to pass in an RPC.
1650 @end{Discussion}
1651
1652 @IndexCheck{Partition_Check}
1653 In a dispatching call with two or more controlling operands that are
1654 designated by values of a remote access-to-class-wide type,
1655 a check is made @Redundant[(in addition to the normal Tag_Check
1656 @em see @RefSecNum{Suppressing Checks})] that all the remote
1657 access-to-class-wide values originated from Access
1658 @nt<attribute_reference>s that were evaluated by tasks of the
1659 same active partition.
1660 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
1661 Constraint_Error is raised if this check fails.
1662 @begin{ImplNote}
1663 When a remote access-to-class-wide value is created by
1664 an Access @nt<attribute_reference>, the identity of the
1665 active partition that evaluated the @nt<attribute_reference>
1666 should be recorded in the representation of the remote access value.
1667 @end{ImplNote}
1668
1669 @end{RunTime}
1670
1671 @begin{ImplReq}
1672
1673 The implementation of remote subprogram calls shall conform
1674 to the PCS interface as defined by the specification of the
1675 language-defined package System.RPC
1676 (see @RefSecNum{Partition Communication Subsystem}).
1677 The calling stub shall use the Do_RPC procedure unless the remote
1678 procedure call is asynchronous in which case Do_APC shall be used.
1679 On the receiving side, the corresponding receiving stub shall be
1680 invoked by the RPC-receiver.
1681 @begin{ImplNote}
1682 One possible implementation model is as follows:
1683
1684 The code for calls to subprograms declared in an RCI
1685 package is generated
1686 normally, that is, the call-site is the same as for a
1687 local subprogram call.
1688 The code for the remotely callable subprogram bodies is also generated
1689 normally. Subprogram's prologue and epilogue are the same as for a local call.
1690
1691 When compiling the specification of an RCI package, the compiler
1692 generates calling stubs for each visible subprogram. Similarly, when
1693 compiling the body of an RCI package, the compiler generates
1694 receiving stubs for each visible subprogram together with the appropriate
1695 tables to allow the RPC-receiver to locate the correct receiving stub.
1696
1697 For the statically bound remote calls, the identity of the remote
1698 partition is statically determined (it is resolved at configuration/link time).
1699
1700 @Leading@;The calling stub operates as follows:
1701 @begin(Itemize)
1702 It allocates (or reuses) a stream of Params_Stream_Type of Initial_Size,
1703 and initializes it by repeatedly calling Write operations,
1704 first to identify which remote subprogram in the receiving partition
1705 is being called, and then to pass the incoming value of each of the
1706 @b(in) and @b(in out) parameters of the call.
1707
1708
1709 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1710 It allocates (or reuses) a stream for the Result,
1711 unless @Chg{Version=[3],New=[an aspect],Old=[a pragma]} Asynchronous is
1712 @Chg{Version=[3],New=[specified as True for],Old=[applied to]} the procedure.
1713
1714 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1715 It calls Do_RPC unless @Chg{Version=[3],New=[an aspect],Old=[a pragma]}
1716 Asynchronous @Chg{Version=[3],New=[is specified as True for],Old=[applied to]}
1717 the procedure
1718 in which case it calls Do_APC. An access value designating the message
1719 stream allocated and initialized above is passed as the Params parameter.
1720 An access value designating the Result stream is passed as the Result
1721 parameter.
1722
1723
1724 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1725 If the @Chg{Version=[3],New=[aspect],Old=[pragma]} Asynchronous is not specified for the procedure,
1726 Do_RPC blocks until a reply message arrives,
1727 and then returns to the calling stub.
1728 The stub returns after extracting
1729 from the Result stream, using Read operations, the @b(in out) and @b(out)
1730 parameters or the function result. If the reply message
1731 indicates that the execution of the remote subprogram propagated
1732 an exception, the exception is propagated from Do_RPC to the
1733 calling stub, and thence to the point of the original remote subprogram call.
1734 If Do_RPC detects that communication with the remote partition has
1735 failed, it propagates Communication_Error.
1736
1737 @end(Itemize)
1738
1739 @Leading@;On the receiving side, the RPC-receiver procedure operates as follows:
1740 @begin(Itemize)
1741 It is called from the PCS when a remote-subprogram-call message is received.
1742 The call originates in some remote call receiver task executed and
1743 managed in the context of the PCS.
1744
1745 It extracts information from the stream to identify the appropriate
1746 receiving stub.
1747
1748 The receiving stub extracts the @b(in) and @b(in out) parameters using
1749 Read from the stream designated by the Params parameter.
1750
1751 The receiving stub calls the actual subprogram body and, upon completion of
1752 the subprogram, uses Write to insert the results into the
1753 stream pointed to by the Result parameter. The receiving stub returns to
1754 the RPC-receiver procedure which in turn returns to the PCS.
1755 If the actual subprogram body propagates an exception, it is propagated
1756 by the RPC-receiver to the PCS, which handles the exception,
1757 and indicates in the reply message that the execution of the
1758 subprogram body propagated an exception. The exception occurrence
1759 can be represented in the reply message using the Write attribute
1760 of Ada.Exceptions.Exception_Occurrence.
1761 @end(Itemize)
1762
1763 For remote access-to-subprogram types:
1764
1765 A value of a remote access-to-subprogram type can be
1766 represented by the following components: a reference to the remote partition,
1767 an index to the package containing the remote subprogram, and an index to
1768 the subprogram within the package. The values of these components are
1769 determined at run time when the remote access value is created.
1770 These three components serve the same purpose when calling Do_APC/RPC,
1771 as in the statically bound remote calls; the only difference is that they
1772 are evaluated dynamically.
1773
1774 For remote access-to-class-wide types:
1775
1776 For each remote access-to-class-wide type,
1777 a calling stub is generated for each dispatching operation of
1778 the designated type. In addition, receiving stubs are generated to perform
1779 the remote dispatching operations in the called partition. The appropriate
1780 @nt{subprogram_body} is determined as for a local
1781 dispatching call once the receiving stub has been reached.
1782
1783 A value of a remote access-to-class-wide type
1784 can be represented with the following components:
1785 a reference to the remote partition, an index to a table (created one per
1786 each such access type) containing addresses of all the dispatching operations
1787 of the designated type, and an access value designating the actual remote
1788 object.
1789
1790 Alternatively, a remote access-to-class-wide value can be represented as
1791 a normal access value, pointing to a "stub" object which in turn
1792 contains the information mentioned above. A call on any
1793 dispatching operation of such a stub object does the remote call,
1794 if necessary, using the information in the stub object to locate
1795 the target partition, etc. This approach has the advantage that
1796 less special-casing is required in the compiler. All access values
1797 can remain just a simple address.
1798
1799 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
1800 For a call to Do_RPC or Do_APC: The partition ID of all controlling
1801 operands are checked for equality (a Constraint_Error is raised if this
1802 check fails). The partition ID value is used for the Partition parameter.
1803 An index into the @i{tagged-type-descriptor} is created. This index
1804 points to the receiving stub of the class-wide operation. This index and
1805 the index to the table (described above) are
1806 written to the stream.
1807 Then, the actual parameters are marshalled into the message
1808 stream. For a controlling operand, only the access value
1809 designating the remote object is required (the other two
1810 components are already present in the other parameters).
1811
1812 On the called partition (after the RPC-receiver has transferred control
1813 to the appropriate receiving stub) the parameters are first unmarshalled.
1814 Then, the tags of the controlling operands (obtained by dereferencing the
1815 pointer to the object) are checked for equality.
1816 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
1817 If the check fails Constraint_Error is raised and propagated back to the
1818 calling partition, unless it is a result of an asynchronous call.
1819 Finally, a dispatching call to the specific subprogram (based on the
1820 controlling object's tag) is made. Note that since this subprogram is not
1821 in an RCI package, no specific stub is generated for it, it is called
1822 normally from the @i{dispatching stub}.
1823
1824 @end{ImplNote}
1825
1826 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0086],ARef=[AI95-00159-01]}
1827 @ChgAdded{Version=[1],Text=[With respect to shared variables in shared
1828 passive library units, the
1829 execution of the corresponding subprogram body of a synchronous remote
1830 procedure call is considered to be part of the execution of the calling task.
1831 The execution of the corresponding subprogram body of an asynchronous remote
1832 procedure call proceeds in parallel with the calling task and does not signal
1833 the next action of the calling task (see @RefSecNum{Shared Variables}).]}
1834 @end{ImplReq}
1835
1836 @begin{Notes}
1837 A given active partition can both make and receive remote subprogram calls.
1838 Thus, an active partition can act as both a client and a server.
1839
1840 If a given exception is propagated by a remote
1841 subprogram call, but the exception does not exist in the calling
1842 partition, the exception can be handled by an @key(others) choice
1843 or be propagated to and handled by a third partition.
1844 @begin{Discussion}
1845 This situation can happen
1846 in a case of dynamically nested remote subprogram calls, where an
1847 intermediate call executes in a partition that does
1848 not include the library unit that defines the exception.
1849 @end{Discussion}
1850 @end{Notes}
1851
1852 @begin{DiffWord95}
1853 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0086],ARef=[AI95-00159-01]}
1854 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Added rules so that tasks can
1855 safely access shared passive objects.]}
1856
1857 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0085],ARef=[AI95-00215-01]}
1858 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that the check on
1859 class-wide types also applies to values returned from remote subprogram call
1860 functions.]}
1861 @end{DiffWord95}
1862
1863 @begin{DiffWord2005}
1864 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0101-1]}
1865 @ChgAdded{Version=[3],Text=[@b<Correction:> Corrected the text to
1866 note that remote access types can be defined in remote types units.]}
1867 @end{DiffWord2005}
1868
1869
1870 @LabeledRevisedSubClause{Version=[3],New=[Asynchronous Remote Calls],Old=[Pragma Asynchronous]}
1871
1872 @begin{Intro}
1873 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1874 @redundant[This subclause introduces the
1875 @Chg{Version=[3],New=[aspect],Old=[pragma]} Asynchronous which
1876 @Chg{Version=[3],New=[can be specified to allow],Old=[allows]} a
1877 remote subprogram call to return prior to completion of the execution
1878 of the corresponding remote subprogram body.]
1879 @end{Intro}
1880
1881 @begin{NotIso}
1882 @ChgAdded{Version=[3],Noprefix=[T],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 2
1883 through 7 were deleted.>}]}@Comment{This message
1884 should be deleted if the paragraphs are ever renumbered.}
1885 @end{NotIso}
1886
1887 @begin{Syntax}
1888 @begin{SyntaxText}
1889 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
1890 @ChgDeleted{Version=[3],Type=[Leading],Text=[The form of a @nt{pragma}
1891 Asynchronous is as follows:]}
1892 @end{SyntaxText}
1893
1894 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1895 @DeletedPragmaSyn<Version=[3],InitialVersion=[0],@ChgDeleted{Version=[3],
1896 Text=[@key{pragma} @prag(Asynchronous)(@Syn2{local_name});]}>
1897 @end{Syntax}
1898
1899 @begin{Legality}
1900 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0229-1]}
1901 @ChgDeleted{Version=[3],Type=[Leading],Text=[The @nt<local_name> of a pragma
1902 Asynchronous shall denote either:]}
1903 @begin{Itemize}
1904 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1905 @ChgDeleted{Version=[3],Text=[One or more remote procedures;
1906 the formal parameters of the procedure(s) shall all be of
1907 mode @key{in};]}
1908
1909 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1910 @ChgDeleted{Version=[3],Text=[The first subtype of a remote
1911 access-to-procedure type; the formal parameters
1912 of the designated profile of
1913 the type shall all be of mode @key{in};]}
1914
1915 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1916 @ChgDeleted{Version=[3],Text=[The first subtype of a remote
1917 access-to-class-wide type.]}
1918 @end{Itemize}
1919 @end{Legality}
1920
1921 @begin{StaticSem}
1922 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1923 @ChgAdded{Version=[3],Type=[Leading],Text=[]}@Comment{Fake to get conditional Leading}
1924 @Chg{Version=[3],New=[For a remote procedure, the following language-defined
1925 representation aspect may be specified:],
1926 Old=[@PDefn2{Term=[representation pragma], Sec=(Asynchronous)}
1927 @PDefn2{Term=[pragma, representation], Sec=(Asynchronous)}
1928 A pragma Asynchronous is a representation pragma.
1929 When applied to a type, it specifies the type-related @i{asynchronous}
1930 aspect of the type.]}
1931 @begin{Description}
1932 @ChgRef{Version=[3],Kind=[Added]}
1933 @ChgAdded{Version=[3],Text=[Asynchronous@\The type of aspect Asynchronous is
1934 Boolean. If directly specified, the @nt{aspect_definition} shall be a static
1935 expression. If not specified, the aspect is False.@AspectDefn{Asynchronous}]}
1936
1937 @ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Asynchronous],
1938 Text=[@ChgAdded{Version=[3],Text=[Remote procedure calls are asynchronous;
1939 the caller continues without waiting for the call to return.]}]}
1940
1941 @end{Description}
1942
1943 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
1944 @ChgAdded{Version=[3],Type=[Leading],Text=[For a remote access type, the
1945 following language-defined representation aspect may be specified:]}
1946 @begin{Description}
1947 @ChgRef{Version=[3],Kind=[Added]}
1948 @ChgAdded{Version=[3],Text=[Asynchronous@\The type of aspect Asynchronous is
1949 Boolean. If directly specified, the @nt{aspect_definition} shall be a static
1950 expression. If not specified (including by inheritance), the aspect is False.]}
1951 @end{Description}
1952 @end{StaticSem}
1953
1954 @begin{Legality}
1955 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
1956 @ChgAdded{Version=[3],Text=[If aspect Asynchronous is specified for a remote
1957 procedure, the formal parameters of the procedure shall all be of mode
1958 @key[in].]}
1959
1960 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0229-1]}
1961 @ChgAdded{Version=[3],Text=[If aspect Asynchronous is specified for a remote
1962 access type, the type shall be a remote access-to-class-wide type, or the type
1963 shall be a remote access-to-procedure type with the formal parameters of the
1964 designated profile of the type all of mode @key[in].]}
1965 @end{Legality}
1966
1967 @begin{RunTime}
1968
1969 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]}
1970 @Defn2{Term=[remote procedure call],Sec=(asynchronous)}
1971 @Defn2{Term=[asynchronous], Sec=(remote procedure call)}
1972 A remote call is @i{asynchronous} if it is a call to a procedure,
1973 or a call through a value of an access-to-procedure type,
1974 @Chg{Version=[3],New=[for],Old=[to]} which
1975 @Chg{Version=[3],New=[aspect],Old=[a pragma]} Asynchronous
1976 @Chg{Version=[3],New=[is True],Old=[applies]}.
1977 In addition, if @Chg{Version=[3],New=[aspect],Old=[a pragma]} Asynchronous
1978 @Chg{Version=[3],New=[is True for],Old=[applies to]} a remote
1979 access-to-class-wide type, then
1980 a dispatching call on a procedure
1981 with a controlling operand designated by a value of the type
1982 is asynchronous if the
1983 formal parameters of the procedure are all of mode @key{in}.
1984 @end{RunTime}
1985
1986 @begin{ImplReq}
1987
1988 Asynchronous remote procedure calls shall be implemented such that the
1989 corresponding body executes at most once as a result of the call.
1990 @begin{Honest}
1991 It is not clear that this rule can be tested or even defined formally.
1992 @end{Honest}
1993 @end{ImplReq}
1994
1995 @begin{Extend2005}
1996 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0229-1]}
1997 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
1998 Aspect Asynchronous is new; @nt{pragma} Asynchronous is now obsolescent.]}
1999 @end{Extend2005}
2000
2001
2002 @LabeledSubClause{Example of Use of a Remote Access-to-Class-Wide Type}
2003
2004 @begin{Examples}
2005 @Leading@i{Example of using a remote access-to-class-wide type to achieve dynamic binding
2006 across active partitions:}
2007 @begin{example}
2008 @key{package} Tapes @key{is}
2009 @key{pragma} Pure(Tapes);
2010 @key{type} Tape @key{is abstract tagged limited private};
2011 @RI{-- Primitive dispatching operations where}
2012 @RI{-- Tape is controlling operand}
2013 @key{procedure} Copy (From, To : @key{access} Tape; Num_Recs : @key[in] Natural) @key{is} @key{abstract};
2014 @key{procedure} Rewind (T : @key{access} Tape) @key{is} @key{abstract};
2015 @RI{-- More operations}
2016 @key{private}
2017 @key{type} Tape @key{is} ...
2018 @key{end} Tapes;
2019
2020 @key{with} Tapes;
2021 @key{package} Name_Server @key{is}
2022 @key{pragma} Remote_Call_Interface;
2023 @RI{-- Dynamic binding to remote operations is achieved}
2024 @RI{-- using the access-to-limited-class-wide type Tape_Ptr}
2025 @key{type} Tape_Ptr @key{is access all} Tapes.Tape'Class;
2026 @RI{-- The following statically bound remote operations}
2027 @RI{-- allow for a name-server capability in this example}
2028 @key{function} Find (Name : String) @key{return} Tape_Ptr;
2029 @key{procedure} Register (Name : @key[in] String; T : @key[in] Tape_Ptr);
2030 @key{procedure} Remove (T : @key[in] Tape_Ptr);
2031 @RI{-- More operations}
2032 @key{end} Name_Server;
2033
2034 @key{package} Tape_Driver @key{is}
2035 @RI{-- Declarations are not shown, they are irrelevant here}
2036 @key{end} Tape_Driver;
2037
2038 @key{with} Tapes, Name_Server;
2039 @key{package body} Tape_Driver @key{is}
2040 @key{type} New_Tape @key{is new} Tapes.Tape @key{with} ...
2041 @key{procedure} Copy
2042 (From, To : @key{access} New_Tape; Num_Recs: @key[in] Natural) @key{is}
2043 @key{begin}
2044 . . .
2045 @key{end} Copy;
2046 @key{procedure} Rewind (T : @key{access} New_Tape) @key{is}
2047 @key{begin}
2048 . . .
2049 @key{end} Rewind;
2050 @RI{-- Objects remotely accessible through use}
2051 @RI{-- of Name_Server operations}
2052 Tape1, Tape2 : @key[aliased] New_Tape;
2053 @key{begin}
2054 Name_Server.Register ("NINE-TRACK", Tape1'Access);
2055 Name_Server.Register ("SEVEN-TRACK", Tape2'Access);
2056 @key{end} Tape_Driver;
2057
2058 @key{with} Tapes, Name_Server;
2059 @RI{-- Tape_Driver is not needed and thus not mentioned in the @nt{with_clause}}
2060 @key{procedure} Tape_Client @key{is}
2061 T1, T2 : Name_Server.Tape_Ptr;
2062 @key{begin}
2063 T1 := Name_Server.Find ("NINE-TRACK");
2064 T2 := Name_Server.Find ("SEVEN-TRACK");
2065 Tapes.Rewind (T1);
2066 Tapes.Rewind (T2);
2067 Tapes.Copy (T1, T2, 3);
2068 @key{end} Tape_Client;
2069 @end{example}
2070
2071 @leading@keepnext@i{Notes on the example}:
2072 @begin{Discussion}
2073 The example does not show the case where tapes are removed from or added to
2074 the system. In the former case, an appropriate exception needs to be defined
2075 to instruct the client to use another tape. In the latter, the Name_Server
2076 should have a query function visible to the clients to inform them about the
2077 availability of the tapes in the system.
2078 @end{Discussion}
2079
2080 @ChgRef{Version=[1], Kind=[Deleted]}
2081 @Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number from original RM}>]
2082
2083 @begin{itemize}
2084 The package Tapes provides the necessary declarations of the type and its
2085 primitive operations.
2086
2087 Name_Server is a remote call interface package and is elaborated in a separate
2088 active partition to provide the necessary naming services (such as Register
2089 and Find) to the entire distributed program
2090 through remote subprogram calls.
2091
2092 Tape_Driver is a normal package that is elaborated in a partition configured
2093 on the processing node that is connected to the tape device(s). The abstract
2094 operations are overridden to support
2095 the locally declared tape devices (Tape1, Tape2). The package is not visible
2096 to its clients, but it exports the tape devices (as remote objects)
2097 through the services of the Name_Server. This allows for tape devices to be
2098 dynamically added, removed or replaced without requiring the modification of
2099 the clients' code.
2100
2101 The Tape_Client procedure references only declarations in the Tapes and
2102 Name_Server packages. Before using a tape for the first time, it needs to
2103 query the Name_Server for a system-wide identity for that tape. From then on,
2104 it can use that identity to access the tape device.
2105
2106 Values of remote access type Tape_Ptr include the necessary information to
2107 complete the remote dispatching operations that result from
2108 dereferencing the controlling operands T1 and T2.
2109
2110 @end{itemize}
2111 @end{Examples}
2112
2113
2114 @NotISORMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
2115 @LabeledClause{Partition Communication Subsystem}
2116
2117 @begin{Intro}
2118 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00273-01]}
2119 @Defn{partition communication subsystem (PCS)}
2120 @Defn{PCS (partition communication subsystem)}
2121 @redundant[The @i{Partition Communication Subsystem} (PCS) provides facilities for
2122 supporting communication between the active partitions of a distributed
2123 program. The package System.RPC is a language-defined interface to the
2124 PCS.]@Chg{Version=[2],New=[],Old=[ An implementation conforming to this
2125 Annex shall use the RPC interface to implement remote subprogram calls.]}
2126 @begin{Reason}
2127 The prefix RPC is used rather than RSC because the term remote procedure call
2128 and its acronym are more familiar.
2129 @end{Reason}
2130 @end{Intro}
2131
2132 @begin{StaticSem}
2133
2134 @leading@keepnext@;The following language-defined library package exists:
2135 @begin{example}
2136 @b(with) Ada.Streams; @RI{-- see @RefSecNum[The Package Streams]}
2137 @key(package) System.RPC @key(is)@ChildUnit{Parent=[System],Child=[RPC]}
2138
2139 @key(type) @AdaTypeDefn{Partition_Id} @key(is range) 0 .. @RI(implementation-defined);
2140
2141 @AdaExcDefn{Communication_Error} : @key(exception);
2142
2143 @key(type) @AdaTypeDefn{Params_Stream_Type} (
2144 Initial_Size : Ada.Streams.Stream_Element_Count) @key(is) @key(new)
2145 Ada.Streams.Root_Stream_Type @key(with) @key(private);
2146
2147 @key(procedure) @AdaSubDefn{Read}(
2148 Stream : @key(in out) Params_Stream_Type;
2149 Item : @key(out) Ada.Streams.Stream_Element_Array;
2150 Last : @key(out) Ada.Streams.Stream_Element_Offset);
2151
2152 @key(procedure) @AdaSubDefn{Write}(
2153 Stream : @key(in out) Params_Stream_Type;
2154 Item : @key(in) Ada.Streams.Stream_Element_Array);
2155
2156
2157 @RI(-- Synchronous call)
2158 @key(procedure) @AdaSubDefn{Do_RPC}(
2159 Partition : @key(in) Partition_Id;
2160 Params : @key(access) Params_Stream_Type;
2161 Result : @key(access) Params_Stream_Type);
2162
2163 @RI(-- Asynchronous call)
2164 @key(procedure) @AdaSubDefn{Do_APC}(
2165 Partition : @key(in) Partition_Id;
2166 Params : @key(access) Params_Stream_Type);
2167
2168 @RI(-- The handler for incoming RPCs)
2169 @key(type) @AdaTypeDefn{RPC_Receiver} @key(is access procedure)(
2170 Params : @key(access) Params_Stream_Type;
2171 Result : @key(access) Params_Stream_Type);
2172
2173 @key(procedure) @AdaSubDefn{Establish_RPC_Receiver}(
2174 Partition : @key(in) Partition_Id;
2175 Receiver : @key(in) RPC_Receiver);
2176
2177 @key[private]
2178 ... -- @RI{not specified by the language}
2179 @b(end) System.RPC;
2180 @end{example}
2181
2182 A value of the type Partition_Id is used to identify a partition.
2183 @ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],Text=[
2184 The range of type System.RPC.Partition_Id.]}]}
2185
2186 An object of the type Params_Stream_Type is used for identifying
2187 the particular remote subprogram that is being called, as
2188 well as marshalling and
2189 unmarshalling the parameters or result of a remote
2190 subprogram call, as part of sending them between partitions.
2191
2192 @redundant[The Read and Write procedures override the corresponding abstract operations
2193 for the type Params_Stream_Type.]
2194
2195 @end{StaticSem}
2196
2197 @begin{RunTime}
2198
2199 The Do_RPC and Do_APC procedures send a message to the active partition
2200 identified by the Partition parameter.
2201 @begin{ImplNote}
2202 It is assumed that the RPC interface is above the message-passing
2203 layer of the network protocol stack and is implemented in terms of it.
2204 @end{ImplNote}
2205
2206 After sending the message, Do_RPC blocks the calling task until a reply
2207 message comes back from the called partition or some error is detected by
2208 the underlying communication system in which case Communication_Error is
2209 raised at the point of the call to Do_RPC.
2210 @begin{Reason}
2211 Only one exception is defined in System.RPC, although many sources of errors
2212 might exist. This is so because it is not always possible
2213 to distinguish among these errors. In particular, it is often impossible to
2214 tell the difference between a failing communication link and
2215 a failing processing node. Additional information might be associated with
2216 a particular Exception_Occurrence for a Communication_Error.
2217 @end{Reason}
2218
2219 Do_APC operates in the same way as Do_RPC except that it
2220 is allowed to return immediately after sending the message.
2221
2222 Upon normal return, the stream designated by the Result parameter
2223 of Do_RPC contains the reply message.
2224
2225 @PDefn2{Term=[elaboration], Sec=(partition)}
2226 The procedure System.RPC.Establish_RPC_Receiver is called
2227 once, immediately after elaborating
2228 the library units of an active partition
2229 (that is, right after the @i{elaboration of the partition}) if the partition
2230 includes an RCI library unit, but prior to invoking the main
2231 subprogram, if any.
2232 The Partition parameter is the Partition_Id of the active partition
2233 being elaborated.
2234 @Defn{RPC-receiver}
2235 The Receiver parameter designates an
2236 implementation-provided procedure called the
2237 @i{RPC-receiver} which will handle all RPCs received by the
2238 partition from the PCS.
2239 Establish_RPC_Receiver saves a reference to the RPC-receiver;
2240 when a message is received at the called partition, the RPC-receiver
2241 is called with the Params stream containing
2242 the message. When the RPC-receiver
2243 returns, the contents of the stream designated by Result is
2244 placed in a message and sent back to the calling partition.
2245 @begin{ImplNote}
2246 It is defined by the PCS implementation whether one or more threads of control
2247 should be available to process incoming messages and to wait for their
2248 completion.
2249 @end{ImplNote}
2250 @begin{ImplNote}
2251 At link-time, the linker provides the RPC-receiver and the necessary tables
2252 to support it. A call on Establish_RPC_Receiver is inserted just before
2253 the call on the main subprogram.
2254 @end{ImplNote}
2255 @begin{Reason}
2256 The interface between the PCS (the System.RPC package) and the
2257 RPC-receiver is defined to be dynamic in order to allow the elaboration
2258 sequence to notify the PCS that all packages have been
2259 elaborated and that it is safe to call the receiving stubs. It is not
2260 guaranteed that the PCS units will be the last to be elaborated, so some
2261 other indication that elaboration is complete is needed.
2262 @end{Reason}
2263
2264 If a call on Do_RPC is aborted, a cancellation message is sent
2265 to the called partition, to request that the execution of the
2266 remotely called subprogram be aborted.
2267 @begin{Honest}
2268 The full effects of this message are dependent on the implementation of
2269 the PCS.
2270 @end{Honest}
2271
2272 @PDefn2{Term=[potentially blocking operation],Sec=(RPC operations)}
2273 @PDefn2{Term=[blocking, potentially],Sec=(RPC operations)}
2274 The subprograms declared in System.RPC are potentially
2275 blocking operations.
2276 @end{RunTime}
2277
2278 @begin{ImplReq}
2279 The implementation of the RPC-receiver shall be reentrant@Redundant[,
2280 thereby allowing concurrent calls on it from the PCS to service
2281 concurrent remote subprogram calls into the partition].
2282 @begin{Reason}
2283 There seems no reason to allow the implementation of RPC-receiver
2284 to be nonreentrant, even though we don't require that every
2285 implementation of the PCS actually perform concurrent calls
2286 on the RPC-receiver.
2287 @end{Reason}
2288
2289 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0087],ARef=[AI95-00082-01]}
2290 @ChgAdded{Version=[1],Text=[An implementation shall not restrict the
2291 replacement of the body of
2292 System.RPC. An implementation shall not restrict children of System.RPC.
2293 @Redundant[The related implementation permissions in the introduction to
2294 Annex A do not apply.]]}
2295 @begin{Reason}
2296 @ChgRef{Version=[1],Kind=[Added]}
2297 @ChgAdded{Version=[1],Text=[The point of System.RPC is to let the user tailor
2298 the communications
2299 mechanism without requiring changes to or other cooperation from the compiler.
2300 However, implementations can restrict the replacement of language-defined units.
2301 This requirement overrides that permission for System.RPC.]}
2302 @end{Reason}
2303 @ChgRef{Version=[1],Kind=[Added],Ref=[8652/0087],ARef=[AI95-00082-01]}
2304 @ChgAdded{Version=[1],Text=[If the implementation of System.RPC is provided by
2305 the user, an implementation shall support remote subprogram calls as specified.]}
2306 @begin{Discussion}
2307 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00273-01]}
2308 @ChgAdded{Version=[2],Text=[If the implementation takes advantage of the
2309 implementation permission to use a different specification for System.RPC,
2310 it still needs to use it for remote subprogram calls, and allow the user
2311 to replace the body of System.RPC. It just isn't guaranteed to be portable
2312 to do so in Ada 2005 - an advantage which was more theoretical than real
2313 anyway.]}
2314 @end{Discussion}
2315 @end{ImplReq}
2316
2317 @begin{DocReq}
2318
2319 The implementation of the PCS shall document whether
2320 the RPC-receiver is invoked from concurrent tasks. If there is an
2321 upper limit on the number of such tasks, this limit shall be documented as
2322 well, together with the mechanisms to configure it (if this is supported).
2323 @ChgImplDef{Version=[2],Kind=[Deleted],InitialVersion=[0],
2324 Text=[@ChgDeleted{Version=[2],
2325 Text=[Implementation-defined aspects of the PCS.]}]}
2326 @ChgDocReq{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
2327 Text=[Whether the RPC-receiver is invoked from concurrent tasks, and if so,
2328 the number of such tasks.]}]}
2329
2330 @end{DocReq}
2331
2332 @begin{ImplPerm}
2333
2334 The PCS is allowed to contain implementation-defined interfaces for
2335 explicit message passing, broadcasting, etc. Similarly, it is allowed
2336 to provide additional
2337 interfaces to query the state of some remote partition (given its partition
2338 ID) or of the PCS itself, to set timeouts and retry parameters, to get more
2339 detailed error status, etc. These
2340 additional interfaces should be provided in child packages of System.RPC.
2341 @ImplDef{Implementation-defined interfaces in the PCS.}
2342
2343 A body for the package System.RPC need not be supplied by the
2344 implementation.
2345 @begin{Reason}
2346 It is presumed that a body for the package System.RPC might be
2347 extremely environment specific. Therefore, we do not require
2348 that a body be provided by the (compiler) implementation. The user
2349 will have to write a body, or acquire one, appropriate for the
2350 target environment.
2351 @end{Reason}
2352
2353 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00273-01]}
2354 @ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0299-1]}
2355 @ChgAdded{Version=[2],Text=[An alternative declaration is allowed for
2356 package System.RPC as long as it provides a set of operations that is
2357 substantially equivalent to the specification defined in this
2358 @Chg{Version=[3],New=[subclause],Old=[clause]}.]}
2359 @begin{Reason}
2360 @ChgRef{Version=[2],Kind=[AddedNormal]}
2361 @ChgAdded{Version=[2],Text=[Experience has proved that the definition
2362 of System.RPC given here is inadequate for interfacing to existing
2363 distribution mechanisms (such as CORBA), especially on heterogeneous
2364 systems. Rather than mandate a change in the mechanism (which would
2365 break existing systems), require implementations to support multiple
2366 mechanisms (which is impractical), or prevent the use of Annex E facilities
2367 with existing systems (which would be silly), we simply make this facility
2368 optional.]}
2369
2370 @ChgRef{Version=[2],Kind=[AddedNormal]}
2371 @ChgAdded{Version=[2],Text=[One of the purposes behind System.RPC was
2372 that knowledgeable users, rather than compiler vendors, could create
2373 this package tailored to their networks. Experience has shown that
2374 users get their RPC from vendors anyway; users have not taken advantage
2375 of the flexibility provided by this defined interface. Moreover, one
2376 could compare this defined interface to requiring Ada compilers to use
2377 a defined interface to implement tasking. No one thinks that the latter is
2378 a good idea, why should anyone believe that the former is?]}
2379
2380 @ChgRef{Version=[2],Kind=[AddedNormal]}
2381 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
2382 @ChgAdded{Version=[2],Text=[Therefore, this
2383 @Chg{Version=[3],New=[subclause],Old=[clause]} is made optional. We considered
2384 deleting the @Chg{Version=[3],New=[subclause],Old=[clause]} outright, but we
2385 still require that users may replace the package (whatever its interface).
2386 Also, it still provides a useful guide to the implementation of this
2387 feature.]}
2388 @end{Reason}
2389 @end{ImplPerm}
2390
2391 @begin{ImplAdvice}
2392
2393 Whenever possible, the PCS on the called partition should
2394 allow for multiple tasks to call the RPC-receiver with
2395 different messages and should allow them to block until the corresponding
2396 subprogram body returns.
2397 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2398 Text=[The PCS should allow for multiple tasks to call the RPC-receiver.]}]}
2399
2400 The Write operation on a stream of type Params_Stream_Type should raise
2401 Storage_Error if it runs out of space trying to write the Item
2402 into the stream.
2403 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
2404 Text=[The System.RPC.Write operation should raise Storage_Error if it runs out
2405 of space when writing an item.]}]}
2406 @begin{ImplNote}
2407 An implementation could also dynamically allocate more space
2408 as needed, only propagating Storage_Error if the @nt<allocator>
2409 it calls raises Storage_Error. This storage could be managed
2410 through a controlled component of the stream object, to
2411 ensure that it is reclaimed when the stream object
2412 is finalized.
2413 @end{ImplNote}
2414
2415 @end{ImplAdvice}
2416
2417 @begin{Notes}
2418 The package System.RPC is not designed for direct calls by user
2419 programs. It is instead designed for use in the implementation of remote
2420 subprograms calls, being called by the calling stubs generated for a
2421 remote call interface library unit to initiate a remote call,
2422 and in turn calling back to an
2423 RPC-receiver that dispatches to the receiving stubs generated
2424 for the body of a remote call interface, to handle a remote call
2425 received from elsewhere.
2426 @end{Notes}
2427
2428 @begin{Incompatible95}
2429 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00273-01]}
2430 @ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
2431 The specification of System.RPC can now be
2432 tailored for an implementation. If a program replaces the body of System.RPC
2433 with a user-defined body, it might not compile in a given implementation
2434 of Ada 2005 (if the specification of System.RPC has been changed).]}
2435 @end{Incompatible95}
2436
2437 @begin{DiffWord95}
2438 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0087],ARef=[AI95-00082-01]}
2439 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that the user can
2440 replace System.RPC.]}
2441 @end{DiffWord95}