Next: Summary of Pragma Shared_Passive, Previous: Overview of Pragma Shared_Passive, Up: Pragma Shared_Passive
In the code below, we define two kinds of shared objects. External_Synchronization requires that the different partitions updating this data synchronize to avoid conflicting operations on shared objects. Internal_Synchronization provides a way to get an atomic operation on shared objects. Note that only entryless protected types are allowed in a shared passive unit; synchronization must be done with protected procedures.
package SharedObjects is
pragma Shared_Passive;
Max : Positive := 10;
type Index_Type is range 1 .. Max;
type Rate_Type is new Float;
type Rates_Type is array (Index_Type) of Rate_Type;
External_Synchronization : Rates_Type;
protected Internal_Synchronization is
procedure Set
(Index : in Index_Type;
Rate : in Rate_Type);
procedure Get
(Index : in Index_Type;
Rate : out Rate_Type);
private
-- implementation removed
end SharedObjects;