A.8 Kernel Initialization Procedure

The initialisation of the kernel starts when the INIT message is received by kernel through the Control Interface. This message contains the name of the parameter file. This file completely defines the application of the kernel and all its parameters. After the message is received kernel constructs the object of class TParamFile representing the parameters in the memory. After successful construction all child processes are spawnded and all their necessary objects are created. The serialized ParamFile is sent to the child processes and all their layers are initialized. The parameters of all processes are read from the TParamFile object.

The initialization procedure has its standard, obligatory part, performed by the layers of the genetic algorithm. It includes the standard initialisation and synchronisation of the processes. In certain points of this standard procedure are performed also the initialization procedures of higher external layers. This mechanism enables adding of the initialization of any external layer to the standard initialization procedure of the kernel. These points are important for the eventual kernel extensions. For an example of an external layer initialization see below.

The initialization is performed in each process in two steps as a call of two virtual methods. Each layer that needs an initialization has to override these methods. To initialize all layers, each layer has to call the method of its predecessor. The main body of the initialization of the processes is performed in the virtual method Init(). This method performs the initialization of all layers in upward direction i.e. lower layers are initialized earlier. Afterward is called also virtual method Prepare() that initializes all layers in the opposite direction i.e. higher layers are prepared earlier. The purpose of this second step of the kernel initialization is to perform some actions that need a partial initialization of all process layers.

In the Fig. A.8.1 you can see the decomposed initialization procedure. It is performed between the layers of genetic algorithm TLocalGA and TGlobalGA. All messages are sent on PRIORITY_LGA. Two messages are sent during the procedure. The first contains serialized ParamFile object, the second has a void body. The message tag is always MT_INIT during the initialization, so we mention just special tags in the Fig. A.8.1.
Note: We do not mention, that during the waiting for specified message also messages indicating an internal error are received.

Figure A.8.1: Standard initialization procedure of the kernel.
CHILD PROCESS
MESSAGES
PARENT PROCESS
TLocalGA::RecieveParams() 
{ 
waitForMsg(MS_PARAMFILE); 
}
(MS_PARAMFILE)
<------------------------
Init() 
{ 
SpawnChildren(); 
SendMsg(MS_PARAMFILE); 
... 
ExternalLayer::Init(); 
} 
Init() 
{ 
... 
ExternalLayer::Init(); 
}
Prepare() 
{ 
ExternalLayer::Prepare(); 
... 
 
Prepare() 
{ 
ExternalLayer::Prepare(); 
... 
 }
.
.
.
 
TLocalGA::SendReadyMsg()
(MS_READY)
------------------------>
waitForMsg(MS_READY) 
}

For an example of the external layer initialization see the Fig. A.8.2. It describes the initialization of the diffusion genetic algorithm. The external layers are, in this case, TDiffusionLGA and TDiffusionGGA. Several messages are sent: first parent process sends a list of selected PIDs to each child process. Due this messages are established the neighbourhood connections between child processes. Then the messages containing the borderland population are exchanged between child processes. For detailed information see diffusion algorithm method.



Figure A.8.2: An example of the external layer initialization procedure.
CHILD PROCESS 1
MESSAGES
PARENT PROCESS
MESSAGES
CHILD PROCESS 2
TDiffusionLGA::Init() 
{ 
waitForMsg(MS_NEIGHBOURS); 
(MS_NEIGHBOURS)
<------------------
TDiffusionGGA:Init() 
{ 
SendMsg(MS_NEIGHBOURS); 
}
(MS_NEIGHBOURS)
------------------>
TDiffusionLGA::Init() 
{ 
waitForMsg(MS_NEIGHBOURS); 
SendMsg(MS_BORDERLAND);
(MS_BORDERLAND)
------------------>
 
(MS_BORDERLAND)
<------------------
SendMsg(MS_BORDERLAND);
waitForMsg(MS_BORDERLAND); 
}
 
waitForMsg(MS_BORDERLAND); 
}
Programmer's Guide Project Antares