[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: posix threads



On Tue, 29 Jun 1999, Toomas Kiisk wrote:

> A thread (or LWP, if you wish) cannot "sit" between kernel and
> user space. Creating a kernel-level thread is much alike ordinary
> process forking, only the resulting "processes" (or threads, or
> LWP's) will share the same static data and descriptor table. See

No. Under Solaris 2, there are in fact three separate entities: kernel-level
threads, lightweight processes, *and* user-level threads. Kernel-level threads
are the only scheduled objects. Whenever you create a process, even if you
don't create any threads, it has exactly one LWP which is connected to exactly
one kernel thread. 

Think about it... If you use only user-threads, you have no control over the
scheduling. If every thread is a kernel thread, the kernel might be doing more
work than necessary. OTOH, if you have an intermediate entity (LWPs), you can
multiplex user-level threads across them. You could have, for example, 5 LWPs
with 10 threads connected to each. Each set of threads will be scheduled
separately by the kernel, and if one thread connected to a LWP blocks, the
rest of the threads on that LWP will have to wait; but the 40 other threads
connected to the other 4 LWPs aren't affected.

This has nothing to do OpenBSD though. You should read Jim Munro's SunWorld
articles on "The Solaris process model" from SunWorld.

  .  _  _  _ _ . .   _ _ .  . _  _  _ . .
 :  |-||-||<|_||\|  |_|-||\/||-'|->|_-|_|_  DalTech, Halifax, NS, Canada
  `---------------------------------------- [http://www.biodome.org/~fx] -