[prev] [up] [next]

Actions performed at Program Startup

Contents

Introduction

This document describes the actions performed at startup time. This may be of interest, if you want to know how classes are initialized and how to add calls to your private C-functions at startup time (for example, to initialize additional c-library packages).

VM Startup

Before any smalltalk activity takes place, some virtual machine (VM) startup actions are performed: The two system files 'symbols.stc' and 'modules.stx' are searched along the following path:
Unix systems:
MS-Windows systems:

Class Initialization

In traditional smalltalk implementations, class initialization is performed once when the class is filedIn the very first time (via the #initialize message at the end of the source file) or manually by the user from within the browser or a workspace.

Since traditional smalltalks always use an image, this will contain the initialized classes with all of their class variables and class instance variables (if any).

In Smalltalk/X no snapshot image is required: it can be started both with and without a snapshot. If started with a snapshot, the behavior is as described above: all objects are read from the image and the classes found there have already executed their #initialize method in the previous live.

If started without an image, all classes' #initialize methods are called at early startup time, sorted by class inheritance. These methods are responsible to create and setup any local objects required for proper operation of the class.
Inside a subclass inheritance level, the order by which those methods are invoked is not defined (i.e. in a classes #initialize method, you may depend on all superclasses being already initialized, but you may NOT depend on any other classes being initialized.

This means:

Smalltalk Startup

During startup the following actions are performed (in the order below):

The followup actions depend on whether this is a clean startup (i.e. without an image) or a startup from a snapshot image.

Clean Startup

A clean startup is performed if no snapshot image is present (or the "-I" command line option was given) or if the image file is not readable.
Notes:
(*)
The runtime system makes certain, that superclasses are initialized before any subclass. However, for classes within the same inheritance level, the order is not defined.
(**)
This is different than it used to be in previous version of ST/X, where no extra process was forked for the startup actions.
The change was made to allow startup actions to readWait on any socket, pipeStream etc., which would not be possible, if the initial process (which runs before the process scheduler is enabled) did this.

Very specialized applications, which do not need process scheduling or which want to implement their own scheduling mechanisms, may use the DIRECT_START feature, to get their own code called, without any standard (ST/X) setups being performed.
However, it is then their responsibility to correctly initialize the system.

Startup with an Image

If a snapshot image is present, initialization order is:

Have a look at the implementation of "Smalltalk restart" to see the followup actions.

Actions Performed by the Script Files

During startup, two script files are consulted (filedIn): "patches" and "smalltalk.rc".

The "patches" script first checks for some required classes to be present in the system, and then looks for a subdirectory called "stxPatches" and (if present) loads all files found there.

The "smalltalk.rc" script sets up various common settings, installs autoloaded classes (see below), consults the scripts "host.rc" and "display.rc", and finally invokes "private.rc".
These other scripts are responsible for host-specific setup (printer setting), display-specific setup (screen/keyboard configuration) and the start of an initial application (the Launcher).

All of those scripts are searched along a common searchPath, and the default scripts as provided with the delivery can be overwritten, by providing a corresponding file in your current directory.

Installation of Autoloaded Classes

Within "smalltalk.rc", you will find the expression:
    Smalltalk installAutoloadedClasses
if a "--autoload" command line argument is present. This will search for all files called "abbrev.stc" under all directories found along the packagePath, and ensures that all of your packages are automatically installed into the system.

Because, this might take a long time (10 or more seconds), depending on the number of directories found and the speed of you disk/network drives, this is no longer done by default (as it used to be).

Shortcut Start with an Image

On UNIX systems, an image can be started directly by entering its name, if the image file has execute permission. Thus, if you saved your image as (say) "myApp", you can make it executable with "chmod +x myApp" and then start it via the simple command "myApp".

On VMS, you can start an image with the DCL command: "@myApp".



Copyright © 1995 Claus Gittinger, all rights reserved

<cg at exept.de>

Doc $Revision: 1.35 $ $Date: 2021/03/13 18:24:52 $