From: hyc@hanauma.jpl.nasa.gov (Howard Chu)
Newsgroups: comp.sys.amiga.advocacy
Subject: Re: Multi-Threaded OS?
Date: 28 Jan 1993 07:16:13 GMT
Organization: SAR Systems Development & Processing, JPL
NNTP-Posting-Host: hanauma.jpl.nasa.gov

In article <32JNXB2w165w@ersys.edmonton.ab.ca> joth@ersys.edmonton.ab.ca (Joe Tham) writes:
>        Digging through some literature on OS/2 and Windows NT, I came 
>across the term "multi-threaded"...  What does this mean for the OS and 
>applications and is the Amiga OS multi-threaded?

Multi-threading has a different significance depending on whether you're
talking about an OS kernel vs a user program. The basic definition still
applies - within a single execution context, you have multiple concurrent
paths of execution. As a very basic example, (which really isn't realistic
for any current OS's I know of...) you might have a single process trying
to perform timed input. One multi-threaded approach would be to have a
single thread execute the read operation, perhaps getting suspended in so
doing, and another thread that executes a countdown loop to actually
perform the timing.

Where things start getting tricky is when the multiple threads can run
thru the exact same code path, touching the exact same variables. Generally,
you need to do some interlocking in your libraries to make sure that things
run consistently, and your user-written code needs to be pretty cautious too.

Multi-threading in a kernel faces pretty similar issues, but generally it's
only a concern in a multi-processor shared-memory based system. In this case,
each processor is executing a "thread" in the kernel. You have to take
extreme care in these situations (consider, e.g., multiple processors trying
to service disk I/O requests, all executing the same filesystem code,
all referencing the same data structures in memory, etc....).

If Commodore is planning to release a multi-processor Amiga, then you'll
want a multi-threaded OS kernel. Otherwise, with only a single CPU, there
really is only a single thread of execution in the kernel. Now, whether or
not user-level multi-threading is provided is still an open question. Just
remember that "lightweight processes" is more hype than anything else. The
original versions of Unix didn't need this concept because Unix processes
were already very simple, and not much context needed to be updated in a
context switch. I suspect that the Amiga's OS is already efficient enough
to be considered a lightweight thread system. It's a foregone conclusion
that anything developed by IBM or Microsoft will be bulky/heavyweight in
its default configuration and will require added pains to take advantage
of so-called lightweight processing and user-level threads...

Of course, I don't know anything at all about the Amiga OS's internals, I'm
an ST hacker. (It's unfortunate, but it seems that MiNT for the Atari also
needs the process/thread distinction. In particular, forks can be very
expensive in the common case, unless quickly followed by an exec. But, at
least the lightweight threads are also supported in the OS.)
-- 
  -- Howard Chu @ Jet Propulsion Laboratory, Pasadena, CA

There's a rough border between genius and insanity, but I'm a dual citizen.