Concurrency in Squeak? Is there any?
Hrefna "GumundsdÛttir"
hrefnag at mmedia.is
Tue Jan 19 15:59:43 UTC 1999
On Tuesday, January 19, 1999 3:32 PM, tim at jump.net [SMTP:tim at jump.net]
wrote:
> Hi, Jens -- you wrote:
> > Anyway, when I try something that loops for some time, everything locks
up
> > until the loop finishes. I'm doing this from the Workspace and
outputting
> > to Transcript. Might I be doing something wrong or is Squeak just a
single
> > thread that vanishes into every object you call and you can't do a
thing
> > until it comes back (sort of)? If this is so, is it impossible for me,
for
> > example, to start two objects one after the other and in the mean time
do
> > something else until they finish their work? What I really like to be
able
> > to do is to send messages to objects and forget about the whole thing;
the
> > objects will take care of them selves and I don't have to hang around
> > waiting for an answer.
>
> Squeak uses cooperative multitasking to run various processes
"concurrently". In this scheme, each process runs until it explicitly
yields the processor. Take a look at the Kernel-Processes classes (Delay,
Process, ProcessorScheduler, Semaphore) for more info.
>
> One way to do what you want (run a concurrent process in the background)
is to put what you want to do in a block, including a Processor yield or
delay in the loop (to allow other processes time to run), and fork it as a
new process. For example:
>
> [1 to: 50 do: [:i | Transcript show: i printString; cr. (Delay
forSeconds: 2) wait]] fork.
>
>
> Hope that helps,
>
> -- Tim Olson
>
Thanks. I think I can use this, but it reminds me of the 'dark ages' of
Windows 3.x, where badly written apps 'stole' the processor :)
Why was multitasking in Squeak done this way? Is there any hope that real
threads (at least green ones) will be implemented?
Jens
More information about the Squeak-dev
mailing list
|