Re: Are LinuxThreads real kernel-level threads?

From: Noah Roberts (nroberts_at_dontemailme.com)
Date: 01/05/04


Date: Sun, 04 Jan 2004 20:31:56 -0800

Todd Knarr wrote:
> In comp.os.linux.misc <l4YJb.746199$Fm2.675587@attbi_s04> Rich H <mynewsmail@datasystemsintegration.com> wrote:
>
>>I understand a call to pthread_create() is actually a clone() wrapper.
>>According to man pages for clone (Linux 2.4.18) - a clone call creates a new
>>process.
>
>
> Yes.
>
>
>>So, my understanding of LinuxThreads is that there is no support for actual
>>kernel-level or user-level threads,,,,,,right?
>
>
> No. LinuxThreads are real kernel-level threads.
>
> Part of the problem is a misconception. Threads are merely processes
> that share a common memory space, set of file descriptors and a lot of
> other things. There's also a little magic worked so it appears that all
> threads share the same process ID.

Oh good, they fixed it....oops no they didn't. No magic done, just
ignore the issue:

ps ax
...
  2644 ? S 0:33 /usr/lib/mozilla/mozilla-bin
  2653 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2654 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2655 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2657 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2678 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2700 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2701 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2703 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2707 ? S 0:00 /usr/lib/mozilla/mozilla-bin
  2740 ? S 0:00 /usr/lib/mozilla/mozilla-bin
...
top
   PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  2644 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:37.03 mozilla-bin
  2653 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2654 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.06 mozilla-bin
  2655 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2657 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.11 mozilla-bin
  2678 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.02 mozilla-bin
  2700 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2701 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2703 nroberts 25 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2707 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin
  2740 nroberts 15 0 205m 66m 143m S 0.0 6.6 0:00.00 mozilla-bin

There are several administrative programs that are screwed up by this
non compliant implementation (by posix standard). Many programs meant to
give you a view of memory usage on the system get bad information
returned by these "processes" that are actually threads. There is no
way for them to tell which is which.

There is nothing saying that threads can't be implemented with
processes, but they are supposed to share the same PID. LinuxThreads do
not share PID and so are not correctly implemented.

NR