>>>>> Dimitris Vyzovitis writes:

    Dimitris> This makes me wonder.  AFAIK, according to their
    Dimitris> definition, threads are supposed to be "lightweight"
    Dimitris> processes.  How are linuxthreads actually implemented?
    Dimitris> ie, do we get the real lightweight process that we are
    Dimitris> supposed to get by the pthreads definitions?  

POSIX 1003.1c is very vague, it's even possible to implement pthreads
with one process (similar to the JDK's green threads implementation).

    Dimitris> The descriptions seen in the discussion so far imply
    Dimitris> that this is not the case, while it should be (and we
    Dimitris> should not have to worry that much about overhead ;-} )

Please take a look at the LinuxThreads FAQ:

  K.1: What is the implementation model for LinuxThreads?

  LinuxThreads follows the so-called "one-to-one" model: each thread is
  actually a separate process in the kernel. The kernel scheduler takes
  care of scheduling the threads, just like it schedules regular
  processes. The threads are created with the Linux clone() system call,
  which is a generalization of fork() allowing the new process to share
  the memory space, file descriptors, and signal handlers of the parent.

  Advantages of the "one-to-one" model include: 

       * minimal overhead on CPU-intensive multiprocessing (with about
         one thread per processor);
       * minimal overhead on I/O operations; 
       * a simple and robust implementation (the kernel scheduler does
         most of the hard work for us).

  The main disadvantage is more expensive context switches on mutex and
  condition operations, which must go through the kernel. This is
  mitigated by the fact that context switches in the Linux kernel are
  pretty efficient.


In contrast to the Linux JDK, the Solaris JDK doesn't use pthreads for
the native threads vm. (The solaris threads library has some additional
functions: suspend, resume, ...)). Also Solaris uses the
"many-to-many" model which allows a larger number of threads.

The biggest disadvantage of the native threads JDK on Linux is
that the number of threads/processes is limited by the kernel and
that native threads cost more memory than green threads.


        Juergen

-- 
Juergen Kreileder, Universitaet Dortmund, Lehrstuhl Informatik V
Baroper Strasse 301, D-44221 Dortmund, Germany
Phone: ++49 231/755-5806, Fax: ++49 231/755-5802

Reply via email to