Lazy Display init (Was: Re: [ENH] Splash screen)

David T. Lewis lewis at mail.msen.com
Sun May 21 15:23:26 UTC 2000


On Thu, May 18, 2000 at 09:33:08PM +0200, Bert Freudenberg wrote:
> On Thu, 18 May 2000, Tim Rowledge wrote:
> 
> > One part of this could be done by adopting the changed semantics of
> > beDisplay that I use on the Acorn; the window is not created
> > until/unless that prim is called. This means that you can create the
> > Display form, draw whatever you want on it and then 'beDisplay' and
> > get the initial view to be whatever you want. I originally did it that
> > way to avoid the ugly blank screen effect and realised it was rather
> > useful for headless images.
> 
> Would you do this for X, too? I guess with David's work to support
> the -headless startup flag it should not be hard ...
> 
> -- Bert
> 

Actually, I did this once before, based on Tim's suggestions. I'm attaching
a copy of my earlier message. This is out of date now, and would need to
be reintegrated into the system, but it's quite straightforward. Some
minor rearrangement of the system snapshot/startup methods was all
that was really needed on the Smalltalk side.

Dave

----- Forwarded message from "David T. Lewis" <lewis at mail.msen.com> -----

Resent-Date: 15 Nov 1999 22:08:57 -0000
Resent-Cc: recipient list not shown: ;
Date: Mon, 15 Nov 1999 17:08:37 -0500
From: "David T. Lewis" <lewis at mail.msen.com>
To: squeak at cs.uiuc.edu
Cc: rowledge at interval.com
Subject: [ENH] Lazy display initialization (was: running headless on Unix)
X-Mailer: Mutt 0.95.4i
In-Reply-To: <Marcel-1.46-1115034838-ab5KL&V at diziet.interval.com>; from Tim Rowledge on Sun, Nov 14, 1999 at 07:48:38PM -0800
Resent-Message-ID: <9fEXFD.A.yQG.5RIM4 at jerry.cs.uiuc.edu>
Resent-From: squeak at cs.uiuc.edu
Reply-To: squeak at cs.uiuc.edu
X-Mailing-List: <squeak at cs.uiuc.edu> archive/latest/12394
X-Loop: squeak at cs.uiuc.edu
Precedence: list
Resent-Sender: squeak-request at cs.uiuc.edu

Well, I'm not the "VM team", but I couldn't think of any good reason not
to do this, so here it is.

On Sun, Nov 14, 1999 at 07:48:38PM -0800, Tim Rowledge wrote:
> On Fri 12 Nov, Bert Freudenberg wrote:
> > AFAIK there is no Unix VM yet that can be run both headless and with a
> > window connection. With Dave's VM process changes it should be fairly
> > straight forward to make one that provides a "-headless" option (as the
> > Windows VM does).
> 
> A long time ago I tried to persuade the VM team to adopt the technique
> I use on the Acorn VM - the window is not created and opened until the
> first use of the beDisplay primitive. Thus you can trivially have a
> headless system just by making sure your image doesn't do that until and
> unless it needs to. If you want a really headless system, you can quite
> simply make sure that debug stuff is done some other way than opening a
> notifier; maybe by sending a message down a socket to a remote debugger
> (oh no, I mentioned sockets....) or whatever. The VM stays the same with
> no need to have two versions. One of the problems is that many GUIs have
> a requirement that you have a window in order to have a window handle in
> order to get events. I suspect there are many ways around this problem.
>

This sounds like a good, simple approach. If I understand
your suggestion, the requirements are:

1) In Intepreter>>primitiveBeDisplay, add a single call to a
function which would cause the physical display to be opened.
This could be, for example:
	self openPhysicalDisplayFor: rcvr.

2) Elsewhere in the support code, for each supported
platform, implement a function:
	int openPhysicalDisplayFor(int displayOop).
For platforms which do not need or want to be able to run
headless, this is a no-op.

3) At the leisure of the various VM implementers, update the
support code (sqXWindow.c in the case of unix) to take
advantage of openPhysicalDisplayFor().

Steps 1 and 2 are trivial but require a bit of coordination,
and step 3 can be done whenever folks get around to it.

Attached is the change set for step 1. I tested steps 2
and 3 on a Linux system and it worked fine after a few
small rearrangements in the system startup methods (also
included in the change set).

- Dave


'From Squeak2.6 of 11 October 1999 [latest update: #1559] on 15 November 1999 at 5:15:48 pm'!
"Change Set:		LazyDisplayInit
Date:			15 November 1999
Author:			David T. Lewis

Permit lazy initialization of the physical display medium, as
suggested by Tim Rowledge <rowledge at interval.com>.

VM support code must at a minimum add a function defined
something like this:
	int openPhysicalDisplayFor(int displayOop) {return 0;}
Note that the displayOop parameter is included to permit future
implementors to provide multiple display support. For example,
a unix Squeak server might support several simultaneous
X window displays on remote workstations.

The openPhysicalDisplayFor() function could also be implemented to
allow a physical display to be opened the first time the function
is called. This allows a simple mechanism for supporting headless
images using a single VM executable.

This change set includes minor rearrangements of a couple of
system startup methods. These changes are sufficient to permit
a lightly hacked unix VM (minor changes in sqXWindow.c) to
start an interactive image without errors using lazy display
initialization.

Credit for the idea goes to Tim Rowledge. Any errors in the
implementation are mine."!


!DisplayScreen class methodsFor: 'snapshots' stamp: 'dtl 11/15/1999 17:01'!
startUp  "DisplayScreen startUp"
	Display beDisplay.
	Display setExtent: self actualScreenSize depth: Display depth
! !


!Interpreter methodsFor: 'I/O primitives' stamp: 'dtl 11/15/1999 11:22'!
primitiveBeDisplay
	"Record the system Display object."

	| rcvr |
	rcvr _ self stackTop.
	self success: ((self isPointers: rcvr) and: [(self lengthOf: rcvr) >= 4]).
	successFlag ifTrue: [
		"record the display object both in a variable and in the specialObjectsOop"
		self storePointer: TheDisplay ofObject: specialObjectsOop withValue: rcvr.
		"if the physical display medium is not yet prepared, do it now"
		self openPhysicalDisplayFor: rcvr.
	].! !


!SystemDictionary methodsFor: 'snapshot and quit' stamp: 'dtl 11/15/1999 16:54'!
snapshot: save andQuit: quit
	"Mark the changes file and close all files. If save is true, save the current state of this Smalltalk in the image file. If quit is true, then exit to the outer shell. The latter part of this method runs when resuming a previously saved image. The resume logic checks for a document file to process when starting up."

	| resuming msg sourceLink |
	save & (SourceFiles at: 2) notNil ifTrue:
		[msg _  (quit
			ifTrue: ['----QUIT----']
			ifFalse: ['----SNAPSHOT----'])
			, Date dateAndTimeNow printString.
		sourceLink _ ' priorSource: ' , LastQuitLogPosition printString.
		self assureStartupStampLogged.
		LastQuitLogPosition _ (SourceFiles at: 2) setToEnd; position.
		self logChange: msg , sourceLink.
		Transcript cr; show: msg].

	self processShutDownList.
	Cursor write show.
	save ifTrue: [resuming _ self snapshotPrimitive.  "<-- PC frozen here on image file"
				resuming ifFalse:
					["Time to reclaim segment files is immediately after a save"
					Smalltalk at: #ImageSegment
						ifPresent: [:theClass | theClass reclaimObsoleteSegmentFiles]]]
		ifFalse: [resuming _ false].
	quit & resuming not ifTrue: [self quitPrimitive].
	self setGCParameters.
	resuming ifTrue: [self clearExternalObjects].
	self processStartUpList.
	Cursor normal show.
	resuming ifTrue: [self readDocumentFile].
	^resuming! !




----- End forwarded message -----





More information about the Squeak-dev mailing list