Next: Node positioning, Previous: Components mapping rules, Up: Ada Mapping Rules
In order for each executable to work correctly, the middleware must be properly set up. In the case of PolyORB, we used an API named ARAO (AADL Runtime API for Ocarina). the setup consists in two phases :
with
and pragma
clauses to initialize the
middleware parameters.
The nature of these with clauses depends on these factors:
The setup is done by including (with
) static or generated
packages. Those packages can be divided into three classes :
Example:
process proc features msg_in : in event data port message; msg_out : out event data port message; end proc; process implementation proc.simple subcomponents th1 : thread sender.simple; th2 : thread receiver.simple; connections event data port msg_in -> th2.msg_in; event data port th1.msg_out -> msg_out; end proc.simple;
The process above contains more than one thread, so the Middleware need to be set up in a multitask mode. The execution of a particular node follows this order: first, it put the information concerning its ports in the middleware memory, then collects the information on the other processes (to which it is connected).
The code of the proc
process is:
with PolyORB.Initialization; with Sn_Servants; with ARAO.Utils; with ARAO.Periodic_Threads; with ARAO.RT_Obj_Adapters; with PolyORB.Setup; with PolyORB.ORB; -- Runtime configuration with ARAO.Setup.Application; pragma Warnings (Off, ARAO.Setup.Application); pragma Elaborate_All (ARAO.Setup.Application); -- Full tasking mode with ARAO.Setup.Tasking.Full_Tasking; pragma Warnings (Off, ARAO.Setup.Tasking.Full_Tasking); pragma Elaborate_All (ARAO.Setup.Tasking.Full_Tasking); with ARAO.Periodic_Threads; with ARAO.RT_Obj_Adapters; procedure proc is use proc_Servants; begin PolyORB.Initialization.Initialize_World; -- Link local RT POA to current node, specifing priority ARAO.RT_Obj_Adapters.Link_To_Obj_Adapter (new proc_Servants.th2_Object, Th2_Ref, 1); -- Collecting the references of the processes to which it's -- connected ARAO.Utils.Get_GIOP_Ref (tr1_th1_Ref, "127.0.0.1", 4000, 1, "th1", "iiop", 1); -- Create a periodic thread ARAO.Periodic_Threads.Create_Periodic_Thread (TP => proc_Servants.th1_Controller'Access); PolyORB.ORB.Run (PolyORB.Setup.The_ORB, May_Poll => True); end proc;
And the code of the generated file ARAO.Setup.Application
is:
with ARAO.Setup.Base; pragma Warnings (Off, ARAO.Setup.Base); pragma Elaborate_All (ARAO.Setup.Base); with PolyORB.Setup.IIOP; pragma Warnings (Off, PolyORB.Setup.IIOP); pragma Elaborate_All (PolyORB.Setup.IIOP); with PolyORB.Setup.Access_Points.IIOP; pragma Warnings (Off, PolyORB.Setup.Access_Points.IIOP); pragma Elaborate_All (PolyORB.Setup.Access_Points.IIOP); -- ORB controller : workers with PolyORB.ORB_Controller.Workers; pragma Warnings (Off, PolyORB.ORB_Controller.Workers); pragma Elaborate_All (PolyORB.ORB_Controller.Workers); -- Multithreaded no priority mode package with ARAO.Setup.Ocarina_OA; pragma Warnings (Off, ARAO.Setup.Ocarina_OA); pragma Elaborate_All (ARAO.Setup.Ocarina_OA); package body ARAO.Setup.Application is -- No protocol set : default : GIOP/IIOP -- No request priority management end ARAO.Setup.Application;
Note that, since no priorities has been set in AADL description, Object Adapter is a generic one.
If thread priorities have been set in AADL description, then ARAO will build a custom Portable Object Adapter. The building of Portable Object Adapter depends of a set of data such has receiver thread priority and stack size, and the number of out ports connected to his thread. A lane will be created for each port, which will contain thread for every connected out port. Lane priority and stack size will be inherited from AADL thread description, or set to default.
Let's modify the previous example by adding priorities to each threads.
process proc features msg_in : in event data port message msg_out : out event data port message; end proc; process implementation proc.simple subcomponents th1 : thread sender.simple {ARAO::Priority => 1}; th2 : thread receiver.simple {ARAO::Priority => 32}; connections event data port msg_in -> th2.msg_in; event data port th1.msg_out -> msg_out; end proc.simple;
Then Ocarina will generate another version of
ARAO.Setup.Application
, which will contain calls to a custom
Object Adapter generator in ARAO.Setup.OA.Multithreaded.Prio
.
-- General setup with ARAO.Setup.Base; pragma Warnings (Off, ARAO.Setup.Base); pragma Elaborate_All (ARAO.Setup.Base); -- Low-level setup packages with PolyORB.Setup.IIOP; pragma Warnings (Off, PolyORB.Setup.IIOP); pragma Elaborate_All (PolyORB.Setup.IIOP); with PolyORB.Setup.Access_Points.IIOP; pragma Warnings (Off, PolyORB.Setup.Access_Points.IIOP); pragma Elaborate_All (PolyORB.Setup.Access_Points.IIOP); -- ORB controller : workers with PolyORB.ORB_Controller.Workers; pragma Warnings (Off, PolyORB.ORB_Controller.Workers); pragma Elaborate_All (PolyORB.ORB_Controller.Workers); -- Multithreaded mode package with ARAO.Setup.OA.Multithreaded.Prio; pragma Warnings (Off, ARAO.Setup.OA.Multithreaded.Prio); pragma Elaborate_All (ARAO.Setup.OA.Multithreaded.Prio); -- priorites-related packages with PolyORB.Types; with ARAO.Threads; with PolyORB.Setup.OA.Basic_RT_Poa; with ARAO.Setup.OA.Multithreaded; -- Initialization-related packages with PolyORB.Initialization; with PolyORB.Utils.Strings; with PolyORB.Utils.Strings.Lists; package body ARAO.Setup.Application is -- No protocol set : default : GIOP/IIOP Threads_Array_Ü : constant ARAO.Threads.Threads_Properties_Array := ((Standard.Natural (1), -- thread th1 Priority Standard.Natural (0), PolyORB.Types.To_PolyORB_String ("th1"), Standard.Natural (0)), (Standard.Natural (32), -- thread th2 Priority Standard.Natural (0), PolyORB.Types.To_PolyORB_String ("th2"), Standard.Natural (2))); package Priority_Manager is new ARAO.Setup.OA.Multithreaded.Prio (Threads_Array_Ü); procedure Initialize; end ARAO.Setup.Application;