Multitasking Scamper (the web browser in Squeak)
Bob Arning
arning at charm.net
Thu Jan 21 01:44:48 UTC 1999
On Tue, 19 Jan 1999 19:11:40 -0500 (EST) "Lex Spoon" <lex at cc.gatech.edu> wrote:
>
>However, I never figured out how to preempt a process in Squeak.... If someone *does* figure it out, it would make Scamper a whole lot nicer to use.
>
Lex,
The approach I've experimented with in the past was to create a higher-priority process to do the interrupting. Below is an alternative to #fork or #forkAt: which allows more than one priority level to be chosen for a process. The priority will be adjusted according to the given time slices, effectively giving the process greater or lesser access to cpu cycles and greater or lesser interruptibility. I haven't fooled with this in some time, so I can't make any guarantees, but I seem to remember it working fairly well - the process being debugged was one of the main problems.
Cheers,
Bob
=============
'From Squeak 2.2beta of Sept 16, 1998 on 20 January 1999 at 8:39:02 pm'!
!BlockContext methodsFor: 'scheduling' stamp: 'RAA 1/20/1999 20:38'!
toggleWith: parameterList
"Run the receiver block with alternating priorities as given by <parameterList>
this allows a process to run at high priority for best speed while dropping down
to a lower priority so that the UI does not completely die. Example:
[self doSomethingLengthy] toggleWith: {6. 600. 3. 400}
"
| newPriority removed wait parms newProcess |
parms _ ReadStream on: parameterList.
newProcess _ [
self value. newProcess _ nil.
] newProcess.
[
newProcess priority: 4; resume.
[newProcess isNil or: [newProcess suspendedContext isNil or:
[newProcess isInDebugger]]] whileFalse: [
parms atEnd ifTrue: [
parms reset.
].
newPriority _ parms next.
wait _ parms next.
removed _ Processor remove: newProcess ifAbsent: [nil].
removed ifNotNil: [
newProcess offList; priority: newPriority.
newProcess resume.
].
(Delay forMilliseconds: wait) wait.
].
] forkAt: 8.
^newProcess! !
=============
More information about the Squeak-dev
mailing list
|