[squeak-dev] Multi-core VMs (was: Suspending process fix)

Michael van der Gulik mikevdg at gmail.com
Thu Apr 30 22:49:42 UTC 2009

(regarding hypothetical implementation of a multi-core capable Squeak VM)

On 4/30/09, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com> wrote:
> 2009/4/30 Michael van der Gulik <mikevdg at gmail.com>:

>> *Most* parts of the VM will continue working fine. The parts that will
>> break... er... some of the parts that will break are:
>> * garbage collection.
>> * allocating memory for new objects.
>> * primitives and devices.
>> * pointer swapping *might* need to be atomic (become:, becomeForward:).
>> * Semaphore signalling.
>> * (more things???)
> I love the *might*
> What happens for example if you change a class definition... Say add
> or remove an instance slot.
> What would happen if the becomeForward on the array of instances and
> subinstances and method dictionaries were not atomic?

Umm... brain cogs turning... umm...

To retain the behaviour that Squeak has now, the safest, least buggy
and easiest way is to do the above operation with a lock on the entire
VM. Currently this is done in ClassBuilder>>update:to: by using
BlockContext>>valueUnpreemptively. Whole VM locks suck, but nobody has
the right to complain unless they've written a better solution.

I'm not even going to bother trying to work out how this could be done
concurrently. There are so many possible bugs. See the loads of
comments in ClassBuilder>>update:to:. Infact, as Philippe Marschall
points out in this thread, there are even existing bugs related to
this - it's even commented as such in

Another option is to make classes and method immutable, so that they
need to be copied when modifications are wanted. This is the approach
I've taken in my Namespaces implementation, but unfortunately you lose
a lot of the malleability of code that makes Smalltalk nice.

> Don't forget Smalltalk environment rely on such in vivo chirurgical
> operations.
> You should better stop running while you or another thread is
> replacing your own leg.

A heart surgeon went to a mechanic to get his motorbike serviced. The
mechanic started some small talk with the heart surgeon: "You know,
our jobs are quite similar. We both take a body, pull it to pieces,
fix or replace any broken parts and put it all back together again. So
how come you get paid so much more than I do?". The surgeon retorted:
"Try doing it with the motor running!".



More information about the Squeak-dev mailing list