[KLUG Members] 2.6 and NPTL

Peter Buxton members@kalamazoolinux.org
Tue, 4 Nov 2003 12:39:51 -0500


On Tue, Nov 04, 2003 at 06:10:34AM -0500, Adam Williams was only escaped
   alone to tell thee:

> Hasn't NPTL been out for awhile?  Or was that just a RedHat thing
> (thought I read something about SuSe and NPTL)?

Considering how raw and new and basic the NPTL API is, it isn't very old
at all.

What RH did was backport a ton of features to 2.4.x. I find it
frightening, but what do I know? ;-) I'm sure 2.6 is a nicer native
environment for NPTL than kludged 2.4.

What changed in the kernel by 2.5.36, I think, was, e.g., scheduling and
kernel thread resources (tracking, &c.). They make threading possible.
The Linux kernel's threading abilities are a superset of the POSIX
Threads (pthreads) standards.  LinuxThreads, NGPT and NPTL map the one
to the other and describe how clone() actually uses those kernel
resources to make and run threads. That's why my processes' appearance
changed so dramatically when the only thing that changed was glibc.

> Can you mark and change in performance? [ I still find the whole
> PID/no-PID debate interesting, not certain which is conceptually
> correct. ]

It's not PID/no-PID. LinuxThreads is fake threads: threads are
light-weight processes: each *needs* a PID. NGPT used an M:N threading
model, where two kinds of threads exist: kernel threads and user
threads. 

Pan example, M:N

1,2,3,4,5,6,7 <-- M Pan Kernel threads <-- Kernel Scheduler

1-7 are the N number of Pan's user threads.  (FreeBSD is using this
model, as well.) The kernel scheduler gives time to the M threads, which
divvy that time out to the N threads. The number of threads here with
PIDs is up to the implementation.

Supposedly, this reduces load on the kernel by limiting the number of
entities the kernel deals with.

Pan example, 1:1

1,2,3,4,5,6,7 <-- Kernel scheduler

With Ingo Molnar's fast O(1) scheduler, the kernel gives time to each
thread directly. Each thread is represented by handles, IDs, and
resources directly. Matt Dillon, who designed the vm for FreeBSD, has a
FreeBSD fork called DragonflyBSD that will use 1:1.

The Linux developers seemed to have plumped for this model because the
M:N overhead merely translated kernel load into machine total load.
Rather than work around it, Molnar redesigned many kernel structures to
make threads as cheap as possible, permitting 1:1 threading.

-- 
I'm obsessed with mental hygiene.