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


Ulm's Oberon Library:
Process


NAME

Process - suspension and termination of the current process

SYNOPSIS

TYPE Name = ARRAY 128 OF CHAR;
VAR name: Name;
VAR id: Name;
VAR host: Name;
TYPE ExitCode = INTEGER;
VAR indicateSuccess: ExitCode;
VAR indicateFailure: ExitCode;
TYPE ExitEvent = POINTER TO ExitEventRec;
TYPE ExitEventRec =
   RECORD
      (Events.EventRec)
      exitcode: ExitCode;
   END;
VAR softTermination: Events.EventType;
VAR termination: Events.EventType;
VAR abort: Events.EventType;
VAR startOfGarbageCollection: Events.EventType;
VAR endOfGarbageCollection: Events.EventType;
TYPE ExitProc = PROCEDURE (code: ExitCode);
TYPE AbortProc = PROCEDURE;
TYPE PauseProc = PROCEDURE;
TYPE Interface = POINTER TO InterfaceRec;
TYPE InterfaceRec =
   RECORD
      exit: ExitProc;
      abort: AbortProc;
      pause: PauseProc;
   END;


PROCEDURE SetHandlers(if: Interface); PROCEDURE TerminateSoftly; PROCEDURE Terminate; PROCEDURE Abort; PROCEDURE Exit(code: ExitCode); PROCEDURE Pause;

DESCRIPTION

Process interfaces the system-dependent calls which allow to suspend or to terminate the current process. Calls to the standard procedure HALT are converted to calls of Process.Exit by the Oberon compiler. Further, Process causes Events to call Abort in case of abortions.

Three string variables are provided that are possibly initialized by more system-dependant modules. These strings can be empty in case they are unknown or not yet initialized.

name
contains a user-readable name of the current process. The process name is suitable for error messages.
id
is similar but attempts to be a more formal identification of the current process.
host
a string that identifies our host.

Exit raises an event of type termination and causes the current process to be terminated. The exit code is passed to the invocation environment. Terminate calls Exit with an exit code of indicateSuccess. Process exits immediately without event handling in case of recursive calls of Exit or Abort.

TerminateSoftly raises an event of type softTermination that asks all running tasks to terminate. In comparison to Terminate, this method gives all tasks the opportunity to terminate gracefully. However, this termination succeeds only if all tasks honor directly or indirectly a softTermination event.

Abort raises an event of type abort and causes the current process to be aborted. This is suitable in case of serious programming errors where post mortem debugging could be of interest.

Pause suspends the execution of the current process. Some system dependent events which are raised from external sources are able to resume suspended processes.

SetHandlers is to be called during initialization time by a module which implements these operations for the given environment. The default interface of Process consists of procedures with endless loops.

Additionally, Process offers the event types startOfGarbageCollection and endOfGarbageCollection which may be used by garbage collectors to indicate start and end of their work (see Storage).

SEE ALSO

Events
event handling
Storage
storage allocating interface
UnixProcess
initializes Process during startup

Edited by: borchert, last change: 2006/08/09, revision: 1.4, converted to HTML: 2006/08/09

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