theKernel 10.0
Loading...
Searching...
No Matches
MkKernel_Setup_libmkkernel_C_API

MkKernel PACKAGE - Setup und Cleanup the tclmkkernelMore...

+ Collaboration diagram for MkKernel_Setup_libmkkernel_C_API:

Functions

void MkSetup (void)
 setup tclmkkernel internal memory …
 
void MkCleanup (void)
 cleanup tclmkkernel internal memory …
 
bool MkHasThread (void)
 
bool MkHasFork (void)
 

Variables

bool MkCleanupActive
 signal that code was triggert by MkCleanup
 

Detailed Description

MkKernel PACKAGE - Setup und Cleanup the tclmkkernel

Initializing a tclmkkernel library depends on the Target-Programming-Language (TPL) and the specific nature of the Programming-Language-Micro-Kernel (PLMK).

In general it is required to call a Setup style funtion as FIRST command because of:

If more than one META library is called only the toplevel Setup is required:

shared library detail

A new tclmkkernel library is initialized with Setup and released again with Cleanup. Both functions are automatically called upon loading and unloading of the shared library.

Example: Definition (C) of the tclmkkernel library startup functions

MK_EXTERN void MK_DECL MkSetup (void) __attribute__ ((constructor(200)));
MK_EXTERN void MK_DECL MkCleanup (void) __attribute__ ((destructor(200)));
#define MK_DECL
#define MK_EXTERN
static library
void MkSetup(void)
setup tclmkkernel internal memory …
void MkCleanup(void)
cleanup tclmkkernel internal memory …

In the Programming-Language-Micro-Kernel (PLMK), a type is defined for each thread, which means that the new tclmkkernel library must be known when the thread starts. This is not a problem as long as the external tclmkkernel library is linked to the application. However, if dlopen is used to load the tclmkkernel library, the current restriction is that the new data type from the tclmkkernel library has not been defined in all existing threads.

The point in time when a library is loaded depends heavily on the programming language used.

‍To avoid all the problems call the Setup directly at the start of the main program.

Example: Start of the LcConfigServer application from the example/cs directory

static void Main(string[] argv) {
LcConfig.Setup();
var srv = MqFactoryCT<LcConfigServer>.Add().New();
try {
srv.LinkCreate(argv);
srv.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception e) {
srv.ErrorCatch(e);
}
srv.Exit();
}

Function Documentation

◆ MkCleanup()

void MkCleanup ( void )

cleanup tclmkkernel internal memory …

/

/noop [MkCleanup] Cleanup will only be recognized once and will be ignored if not called in the same thread as Setup. After a call to Setup the call to MkCleanup is possible again.

  1. By default, the public Cleanup with the gcc: __attribute__ ((cleanup(XXX))) is called when unloading the library.
  2. The public Cleanup is only a placeholder and should not be used, the internal Cleanup is always called, even if the public Cleanup is not called.
Note
during cleanup objects will be deleted too -> the language interpreter have to be active /noop [MkCleanup]
+ Here is the caller graph for this function:

◆ MkHasFork()

bool MkHasFork ( void )

◆ MkHasThread()

bool MkHasThread ( void )

◆ MkSetup()

void MkSetup ( void )

setup tclmkkernel internal memory …

Setup will only be recognized once, additional call's will be ignored until a Cleanup is called.

  1. By default, the public Setup with the gcc: __attribute__ ((constructor(XXX))) is called when loading the library.
  2. If the Target-Programming-Language (TPL) supports late loading of a shared library with dlopen and additionally uses threads, a manual call to Setup very early at startup is required to enforce the correct order of type declarations.

Variable Documentation

◆ MkCleanupActive

bool MkCleanupActive
extern

signal that code was triggert by MkCleanup