On 26.02.2009, at 01:22, GeertC wrote:
What is the first thing the VM does when starting an image? I want to learn more about how the image actually works.
It simply continues where ever the image was stopped. Select the following two lines in a workspace and "do it":
Smalltalk snapshot: true andQuit: true. self inform: 'Welcome back!'.
This will save the image and quit Squeak, and when you restart it, the informer will show.
In contrast to most other systems, Squeak is not bootstrapped. When you save the image, a primitive is invoked that snapshots the executing state of the system, and when you start an image, it restores the state, and continues right where it left off.
There are, however some actions performed before snapshotting, and right after restarting. It's an extensible design. You can find it in the #snapshot:andQuit: method. There is a line like this:
ifFalse: [self snapshotPrimitive]. "<-- PC frozen here on image file"
Everything following that line is performed on startup. Basically, classes can register to be called at shutdown and/or at startup time, see #processShutDownList: and #processStartUpList:.
- Bert -