[comp.lang.smalltalk] ST-80 Processes and pre-emption

yon@apollo.HP.COM (David Yon) (04/10/90)

Hey there Smalltalk-80 hackers...

	I'm working on prototyping a system which requires us to explore
concurrency issues.  Our model is of a central messaging server connected
to several running tools.  The message server and each tool will probably
map one-to-one to a UNIX process in the final product.

	The problem is as follows.  We really, really want this thing to 
simulate the final environment as closely as possible.  One of the things
we want to simulate is each of these processes marching ahead using UNIX
the pre-emptive multitasking model.  In Smalltalk-80 (in 2.3 at least) 
multi-tasking is NOT preemptive.  A process has control until it explicitly
terminates or suspends.

	Seems to me that anyone who has had to use Smalltalk to simulate 
real-world events must have run up against this.  Any good/bad experiences
out there?  Thanks...

David Yon
Apollo Computer

schang@netcom.UUCP (Sehyo Chang) (04/11/90)

In article <49b89829.20b6d@apollo.HP.COM> yon@apollo.HP.COM (David Yon) writes:
>
>Hey there Smalltalk-80 hackers...

>
>	I'm working on prototyping a system which requires us to explore
>concurrency issues.  Our model is of a central messaging server connected
>to several running tools.  The message server and each tool will probably
>map one-to-one to a UNIX process in the final product.
>
>	The problem is as follows.  We really, really want this thing to 
>simulate the final environment as closely as possible.  One of the things
>we want to simulate is each of these processes marching ahead using UNIX
>the pre-emptive multitasking model.  In Smalltalk-80 (in 2.3 at least) 
>multi-tasking is NOT preemptive.  A process has control until it explicitly
>terminates or suspends.
>
>	Seems to me that anyone who has had to use Smalltalk to simulate 
>real-world events must have run up against this.  Any good/bad experiences
>out there?  Thanks...
>

There are two strategies:

(1) write full discrete event event simulator (on Blue Book, there is chapter
    on discrete event simulation at end).  Model message passing as
    event and write (a) UNIX process object (b) pre-emptive multitaksing
    event manager which handles generation of proper events such that
    pre-emptive is fully simulated.  By default, full discrete event simulator
    is multi-tasking, however, you need to build some process termination/
    interrupt logic. *Warning: make sure you save images often when you
    are doing these sort of things

(2) build special processor scheduler which can do pre-emptive interrupt.
    Idea is to put *Delay* process as higher than normal priority process.
    When that Delay process wakes up it suspends current running process
    and restart other waiting processes.  I do not recommed you put
    this scheduler as system default scheduler because there is other
    processes to content with(for example, current active window controller
    which may during text editing, do 'Process yield', thus may encounter
    race condition.  What you can do is just coordinate only UNIX alike
    processes.

Anyway, doing simulation in Smalltalk is awful lots of *fun*, especially
since lightweight processes doesn't take much weight as real UNIX process.
It is awesome to see 1000 smalltalk processes doing simulation
-- 
Sehyo Chang						schang@netcom.uucp
Ascent Logic Corp.			  ucvbax!ames!apple!netcom!schang
(408)943-0630