Next: Code Generation for Array Aggregates, Previous: GNAT Implementation of Tasking, Up: Implementation of Specific Ada Features
GNAT fully implements the pragma Shared_Passive for .. index:: pragma Shared_Passive
the purpose of designating shared passive packages. This allows the use of passive partitions in the context described in the Ada Reference Manual; i.e., for communication between separate partitions of a distributed application using the features in Annex E. .. index:: Annex E
However, the implementation approach used by GNAT provides for more extensive usage as follows:
The implementation approach used is to store the data in files. A separate stream file is created for each object in the package, and an access to an object causes the corresponding file to be read or written.
The environment variable SHARED_MEMORY_DIRECTORY should be set to the directory to be used for these files. The files in this directory have names that correspond to their fully qualified names. For example, if we have the package
package X is pragma Shared_Passive (X); Y : Integer; Z : Float; end X;
and the environment variable is set to /stemp/, then the files created will have the names:
/stemp/x.y /stemp/x.z
These files are created when a value is initially written to the object, and the files are retained until manually deleted. This provides the persistence semantics. If no file exists, it means that no partition has assigned a value to the variable; in this case the initial value declared in the package will be used. This model ensures that there are no issues in synchronizing the elaboration process, since elaboration of passive packages elaborates the initial values, but does not create the files.
The files are written using normal Stream_IO access. If you want to be able to communicate between programs or partitions running on different architectures, then you should use the XDR versions of the stream attribute routines, since these are architecture independent.
If active synchronization is required for access to the variables in the
shared passive package, then as described in the Ada Reference Manual, the
package may contain protected objects used for this purpose. In this case
a lock file (whose name is ___lock
(three underscores)
is created in the shared memory directory.
This is used to provide the required locking semantics for proper protected object synchronization.
GNAT supports shared passive packages on all platforms except for OpenVMS.