Threading in linux

Threading in linux

am 24.04.2007 08:38:40 von Rick Brown

Hi list,

I read that the kernel does not differentiate between threads and
processes. That means, we can say that on a Linux system, the
threading is purely provided by user level thread libraries, right?

So as long as relevant system calls do not change, it should be
possible to run any threading library on any kernel? NPTL on 2.4?
pthreads on 2.6?

Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 09:03:53 von pradeep singh

On 4/24/07, Rick Brown wrote:
> Hi list,
>
> I read that the kernel does not differentiate between threads and
> processes. That means, we can say that on a Linux system, the
> threading is purely provided by user level thread libraries, right?
>
> So as long as relevant system calls do not change, it should be
> possible to run any threading library on any kernel? NPTL on 2.4?
> pthreads on 2.6?

Yes, looks to me.

HTH
~psr

>
> Rick
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>


--
play the game
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 09:17:23 von Amol Lad

On Tue, 2007-04-24 at 12:08 +0530, Rick Brown wrote:
> Hi list,
>
> I read that the kernel does not differentiate between threads and
> processes.

Only for scheduling. Kernel maintains thread level data structures to
enable say fast context switch, mm sharing etc

>
> So as long as relevant system calls do not change, it should be
> possible to run any threading library on any kernel? NPTL on 2.4?
> pthreads on 2.6?

NPTL needs kernel support. It is 1:1 threading model without any
overhead under the assumption that kernel supports faster context
switches, less kernel entry overhead etc

>
> Rick
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 10:29:41 von Rick Brown

On 4/24/07, Amol Lad wrote:
> On Tue, 2007-04-24 at 12:08 +0530, Rick Brown wrote:
> > Hi list,
> >
> > I read that the kernel does not differentiate between threads and
> > processes.
>
> Only for scheduling. Kernel maintains thread level data structures to
> enable say fast context switch, mm sharing etc

Could you please give an examples?

>
> >
> > So as long as relevant system calls do not change, it should be
> > possible to run any threading library on any kernel? NPTL on 2.4?
> > pthreads on 2.6?
>
> NPTL needs kernel support. It is 1:1 threading model without any
> overhead under the assumption that kernel supports faster context
> switches, less kernel entry overhead etc

AFAIK, all support that a kernel can provide userspace is in terms of
system calls. Do you mean that NPTL needs support in form of some
special syscalls? Or may be /dev/kmem etc?

Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 11:54:49 von Erik Mouw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Apr 24, 2007 at 12:08:40PM +0530, Rick Brown wrote:
> I read that the kernel does not differentiate between threads and
> processes.

Correct.

> That means, we can say that on a Linux system, the
> threading is purely provided by user level thread libraries, right?

No. User level thread libraries are usually things like LWP (light
weight processes), that's not what the Linux kernel uses. The Linux
clone() system call is a superset of the standard Unix fork() system
call. With clone() you can tell what parent and child have to share. A
thread is just an execution context that shares the protection context
with its parent.

> So as long as relevant system calls do not change, it should be
> possible to run any threading library on any kernel? NPTL on 2.4?
> pthreads on 2.6?

Not sure about that. There were certainly issues, though I can't
remember exactly what.


Erik

- --
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGLdPp/PlVHJtIto0RAoV4AJ9+NUu6wSCAniqHGebFcryzJ4pt1ACf fRFC
062W3+mce5yHafv4Ryjc/G4=
=LAWy
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 12:08:04 von vapier.adi

On 4/24/07, Rick Brown wrote:
> So as long as relevant system calls do not change, it should be
> possible to run any threading library on any kernel?

this statement is correct ... not that i see the point of it

> NPTL on 2.4?

this can be done only if you backport the features from 2.6 that were
added in order to make NPTL possible ... redhat has done this, but
really it's just a waste of time ... 2.4 is dead :P

> pthreads on 2.6?

i really have no idea what you mean by this ... "pthreads" is short
for "POSIX threads" and there's no such thing as "pthreads" with
respect to a specific code base. NPTL is one implementation of the
POSIX threads specification while LinuxThreads is another.
-mike
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 12:36:33 von Rick Brown

> > NPTL on 2.4?
>
> this can be done only if you backport the features from 2.6 that were
> added in order to make NPTL possible ... redhat has done this, but
> really it's just a waste of time ... 2.4 is dead :P

Could you hint upon the kernel features required for NPTL? May be a link?

>
> > pthreads on 2.6?
>
> i really have no idea what you mean by this ... "pthreads" is short
> for "POSIX threads" and there's no such thing as "pthreads" with
> respect to a specific code base. NPTL is one implementation of the
> POSIX threads specification while LinuxThreads is another.
> -mike

Sorry ... I meant LinuxThreads.

Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 24.04.2007 12:51:47 von vapier.adi

On 4/24/07, Rick Brown wrote:
> > > NPTL on 2.4?
> >
> > this can be done only if you backport the features from 2.6 that were
> > added in order to make NPTL possible ... redhat has done this, but
> > really it's just a waste of time ... 2.4 is dead :P
>
> Could you hint upon the kernel features required for NPTL? May be a link?

i couldnt really guess. your only safe bet is to go get a redhat
kernel. i think it's a waste either way, but that's me.

> > > pthreads on 2.6?
> >
> > i really have no idea what you mean by this ... "pthreads" is short
> > for "POSIX threads" and there's no such thing as "pthreads" with
> > respect to a specific code base. NPTL is one implementation of the
> > POSIX threads specification while LinuxThreads is another.
>
> Sorry ... I meant LinuxThreads.

linuxthreads works fine on 2.6 ... linux has forward binary
compatibility, thus things that work in 2.4 (like linuxthreads)
continue to work in 2.6
-mike
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Threading in linux

am 25.04.2007 02:48:51 von John Aspinall

Rick Brown wrote:
>
> Could you hint upon the kernel features required for NPTL? May be a link?

I know very little about this, but by coincidence (the application
program I work on got a nice bugfix because of this) I can tell you one
kernel difference on x86_64 kernels that support NPTL.

For NPTL on x86_64, the kernel reserves a register for thread-ID. That
register is swapped as part of the context switch the kernel does. In
the older LinuxThreads, thread-ID was established by looking up a stack
address in a table. In the LinuxThreads implementation, thread-ID was
broken whenever a thread ran on the alt-stack.

John Aspinall
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs