public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* Threading in linux
@ 2007-04-24  6:38 Rick Brown
  2007-04-24  7:03 ` pradeep singh
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Rick Brown @ 2007-04-24  6:38 UTC (permalink / raw)
  To: kernelnewbies, linux-newbie

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24  6:38 Threading in linux Rick Brown
@ 2007-04-24  7:03 ` pradeep singh
  2007-04-24  7:17 ` Amol Lad
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: pradeep singh @ 2007-04-24  7:03 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

On 4/24/07, Rick Brown <rick.brown.3@gmail.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24  6:38 Threading in linux Rick Brown
  2007-04-24  7:03 ` pradeep singh
@ 2007-04-24  7:17 ` Amol Lad
  2007-04-24  8:29   ` Rick Brown
  2007-04-24  9:54 ` Erik Mouw
  2007-04-24 10:08 ` Mike Frysinger
  3 siblings, 1 reply; 9+ messages in thread
From: Amol Lad @ 2007-04-24  7:17 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24  7:17 ` Amol Lad
@ 2007-04-24  8:29   ` Rick Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Rick Brown @ 2007-04-24  8:29 UTC (permalink / raw)
  To: Amol Lad; +Cc: kernelnewbies, linux-newbie

On 4/24/07, Amol Lad <amol@verismonetworks.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24  6:38 Threading in linux Rick Brown
  2007-04-24  7:03 ` pradeep singh
  2007-04-24  7:17 ` Amol Lad
@ 2007-04-24  9:54 ` Erik Mouw
  2007-04-24 10:08 ` Mike Frysinger
  3 siblings, 0 replies; 9+ messages in thread
From: Erik Mouw @ 2007-04-24  9:54 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

-----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+NUu6wSCAniqHGebFcryzJ4pt1ACffRFC
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24  6:38 Threading in linux Rick Brown
                   ` (2 preceding siblings ...)
  2007-04-24  9:54 ` Erik Mouw
@ 2007-04-24 10:08 ` Mike Frysinger
  2007-04-24 10:36   ` Rick Brown
  3 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2007-04-24 10:08 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

On 4/24/07, Rick Brown <rick.brown.3@gmail.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24 10:08 ` Mike Frysinger
@ 2007-04-24 10:36   ` Rick Brown
  2007-04-24 10:51     ` Mike Frysinger
  2007-04-25  0:48     ` John Aspinall
  0 siblings, 2 replies; 9+ messages in thread
From: Rick Brown @ 2007-04-24 10:36 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: kernelnewbies, linux-newbie

> > 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24 10:36   ` Rick Brown
@ 2007-04-24 10:51     ` Mike Frysinger
  2007-04-25  0:48     ` John Aspinall
  1 sibling, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-04-24 10:51 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

On 4/24/07, Rick Brown <rick.brown.3@gmail.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Threading in linux
  2007-04-24 10:36   ` Rick Brown
  2007-04-24 10:51     ` Mike Frysinger
@ 2007-04-25  0:48     ` John Aspinall
  1 sibling, 0 replies; 9+ messages in thread
From: John Aspinall @ 2007-04-25  0:48 UTC (permalink / raw)
  To: Rick Brown; +Cc: kernelnewbies, linux-newbie

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-04-25  0:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-24  6:38 Threading in linux Rick Brown
2007-04-24  7:03 ` pradeep singh
2007-04-24  7:17 ` Amol Lad
2007-04-24  8:29   ` Rick Brown
2007-04-24  9:54 ` Erik Mouw
2007-04-24 10:08 ` Mike Frysinger
2007-04-24 10:36   ` Rick Brown
2007-04-24 10:51     ` Mike Frysinger
2007-04-25  0:48     ` John Aspinall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox