Newsgroups: comp.sys.next
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!rice!uw-beaver!ubc-cs!sritchie
From: sritchie@cs.ubc.ca (Stuart Ritchie)
Subject: Re: Don't believe that SunOS Threads are equivalent to Mach's
Message-ID: <1991May6.231923.19489@cs.ubc.ca>
Sender: usenet@cs.ubc.ca (Usenet News)
Organization: University of British Columbia, Vancouver, B.C., Canada
References: <9105040321.AA00869@lhs.woodside.ca.us> <SCOTT.91May5180102@nic.gac.edu>
Date: Mon, 6 May 91 23:19:23 GMT

In article <SCOTT.91May5180102@nic.gac.edu> scott@nic.gac.edu (Scott Hess) writes:
>Before the flame-wars begin, I'd like to clarify that a bit.  The Sun
>implementation of threads is done fairly high in the OS, I believe -
>it's somewhat akin to the many implementations of threads that I've
>seen in the public domain for anything from MSDOS PCs to BSD Unix
>machines.  Basically, what happens is that the user process sets up
>seperate stacks and all, and a timer which is used to periodically
>switch between threads in the program - this is all handled in
>libraries compiled into the program, not in the OS.
>
>Meanwhile, Mach threads occur "under" Unix.  Mach has threads in
>the first place, and layering Unix over Mach doesn't do much to
>that.  When you use threads, you are using _Mach_ threads,
>rather than _Unix_ threads.  If you wanted, you could even
>implement regular Unix threads on top of what's there (though I
>fail to see any reason why you'd want to).  But, overall Mach
>threads are much more like seperate processes than Unix threads
>are (though not that close, I guess :-).

What's being debated here is kernel supported vs. user level
supported threads.

I want to use user level supported threads
for efficiency: trapping to operations in the kernel is at least
10 times more expensive than a procedure call.  (Has anybody
measured this in practice?  I'm interested in hearing about it.)

Kernel supported threads offer greater flexibility.  Especially
in a multiprocessor environment, where you might have threads of
the same task scheduled on different processors.  One may have
to be more careful about synchronization (eg. critical sections)
though.

Another flexibility with kernel supported threads is IPC.  Notice
that in Mach, one thread can communicate with any other thread
in the system.  The kernel acts as a centralized nameserver for
ports.  Doing this at user level would probably be more expensive.

...Stuart
