Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
SysMain


NAME

SysMain - determine initialization order

SYNOPSIS

VAR mainTaskFinished: Events.EventType;

DESCRIPTION

SysMain is initialized by the runtime startoff after building up the data structures of SysModules and serves as handle for code which determines the initialization order of the other modules.

Not all modules which are linked together need to be initialized. This could be useful if the decision about the module selection depends on command line arguments or the environment.

The module bodies protect themselves against multiple executions and each module body calls the initialization part of all imported modules.

The default implementation of SysMain creates a task group of RoundRobin (which becomes the default task group of Tasks) and adds as first task a coroutine which initializes all modules in linkage order:

PROCEDURE InitAllModules;
   VAR
      module: SysModules.Module;
BEGIN
   module := SysModules.modules;
   WHILE module # NIL DO
      module.init;
      module := module.next;
   END;
END InitAllModules;

Note that SysMain, and, in consequence, the process does not necessarily terminate when InitAllModules terminates. SysMain returns when there are no living tasks of the main task group (InitAllModules is just one of these tasks).

The SysMain implementation is expected to raise an event of the type mainTaskFinished as soon as all modules are initialized. This gives all modules the opportunity to shutdown unneeded tasks to allow the process to terminate if no real activities continue.

SEE ALSO

RoundRobin
round robin scheduler which manages the main task group
Schedulers
general scheduler interface which is supported by RoundRobin
SysModules
list of modules

Edited by: borchert, last change: 2004/03/02, revision: 1.6, converted to HTML: 2004/03/03

Oberon || Library || Module Index || Search Engine || Definition || Module