Multithreading (was: Writing an OS for PC)

Jecel Mattos de Assumpcao Jr.
Wed, 31 May 1995 15:43:18 -0300

Just a few quick notes about the subject.

First is that David Logan dream OS is obviously colored by his IBM
background. I am not saying this is a bad thing - just that if he
had come from a Burroughs background he would be more impressed with
software protection than with hardware. I like to understand all
points of view, though that is not very easy.

The current Self implementation uses a cooperative model much like
Faré is describing. If an assynchronous event happens, it is simply
stored and execution continues until the next "interrupt points".
These interrupt points check for pending events and handle them.
They are inserted by the compiler at message sends and at the end
of loops that don't contain any message sends, so they occur frequently
enough not to cause problems. The big deal about all this is that
the compiler can use any optimization it wants between interrupt
points without losing source level debugging. Other systems simply
can't debug optimized code, so this is a very important point.

When designing Merlin, I initially had a cooperative tasking model
which avoided a lot of saving and restoring of registers. As one
of my objectives was allowing the user to creat arbitrary assembly
language "primitives", however, I decided to play it safe with a
preemptive model. Maybe I should review that decision as I no
longer allow assembly primitives ( but I do allow "virtual assembly"
primitives which aren't quite as bad ).

My idea is to devide a system ( a network of machines, for example )
into "sessions". Hardware protection will isolate the sessions from
each other, but software protection will be much more efficient
within a session.

Smalltalk has a cooperative scheme within a given priority level
while still allowing the system to have preemption among levels.
Whether this is the best of both worlds, or the worst, I'll let
the reader decide :-)

-- Jecel