kernel thread VS user space thread in linux

kernel thread VS user space thread in linux

Post by Jimmy Zhan » Sat, 23 Mar 2002 18:04:33



I got a question concerning the pthread implementation in Linux.
Well, I have all the world telling me pthread for linux is a user-space
thread model, but when I ran a multi-threaded app on linux and turn
on top, I remember seeing multiple copies of the same process on the
process list so a scheduler sees each thread as a process and schedule
it accordingly. But is this what I am supposed to expect from a kernel
thread implementation?

Jimmy Zhang

 
 
 

kernel thread VS user space thread in linux

Post by Rex Diete » Sat, 23 Mar 2002 22:52:10



Quote:> I got a question concerning the pthread implementation in Linux.
> Well, I have all the world telling me pthread for linux is a user-space
> thread model,

I think your "all the world" is wrong.  At least recent pthread
implementation in linux is kernel-space (not user-space) threads.

--
Rex Dieter
Computer System Administrator
Department of Mathematics and Statistics
University of Nebraska Lincoln

 
 
 

kernel thread VS user space thread in linux

Post by Jirka Kosin » Sat, 23 Mar 2002 23:36:49



> I got a question concerning the pthread implementation in Linux.
> Well, I have all the world telling me pthread for linux is a user-space
> thread model, but when I ran a multi-threaded app on linux and turn
> on top, I remember seeing multiple copies of the same process on the
> process list so a scheduler sees each thread as a process and schedule
> it accordingly. But is this what I am supposed to expect from a kernel
> thread implementation?

AFAIK pthread implementation in linux is using clone() syscall, which is
resembling fork(), but allowing two processes to share execution contexts
(i.e to have same memory, but separate stacks).

So linux implementation of pthreads is afaik kernel-space.

--
JiKos.

 
 
 

kernel thread VS user space thread in linux

Post by Norman Blac » Sun, 24 Mar 2002 05:28:21


It all depends on what you mean my "user space". The LinuxThreads
(pthreads) library is implemented in user space (it is a shared object).
It uses the system clone API call to create the threads and the threads
are scheduled (time sliced) by the kernel.

--
Norman Black
Stony Brook Software
nospam => stonybrk


Quote:> I got a question concerning the pthread implementation in Linux.
> Well, I have all the world telling me pthread for linux is a
user-space
> thread model, but when I ran a multi-threaded app on linux and turn
> on top, I remember seeing multiple copies of the same process on the
> process list so a scheduler sees each thread as a process and schedule
> it accordingly. But is this what I am supposed to expect from a kernel
> thread implementation?

> Jimmy Zhang

 
 
 

kernel thread VS user space thread in linux

Post by Eric P. McC » Sun, 24 Mar 2002 06:24:20



> It all depends on what you mean my "user space". The LinuxThreads
> (pthreads) library is implemented in user space (it is a shared object).
> It uses the system clone API call to create the threads and the threads
> are scheduled (time sliced) by the kernel.

Please put your reply below the quoted text, as I have done.

I can't think of any sensible definition of "user space" that
describes how threads are implemented in Linux.

--

"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj

 
 
 

kernel thread VS user space thread in linux

Post by Norman Blac » Sun, 24 Mar 2002 08:16:14




Quote:> Please put your reply below the quoted text, as I have done.

Fashion police?

Quote:> I can't think of any sensible definition of "user space" that
> describes how threads are implemented in Linux.

"user space" as I used it, means the user address space, as opposed to
kernel/supervisor address space. The pthreads library runs in the user
address space, which means no address space change, or context switch,
is necessary when calling the pthreads API calls. An important
performance distinction, that really shows up on uncontested mutex
calls.

What terminology would you use to distinguish between the pthreads APIs
being implemented in a shared object running in the user address space
and implemented in the kernel via system calls?

--
Norman Black
Stony Brook Software
nospam => stonybrk




> > It all depends on what you mean my "user space". The LinuxThreads
> > (pthreads) library is implemented in user space (it is a shared
object).
> > It uses the system clone API call to create the threads and the
threads
> > are scheduled (time sliced) by the kernel.

> Please put your reply below the quoted text, as I have done.

> I can't think of any sensible definition of "user space" that
> describes how threads are implemented in Linux.

> --

> "Last I checked, it wasn't the power cord for the Clue Generator that
> was sticking up your ass." - John Novak, rasfwrj

 
 
 

kernel thread VS user space thread in linux

Post by Eric P. McC » Sun, 24 Mar 2002 08:31:09



> > Please put your reply below the quoted text, as I have done.
> Fashion police?

No, just giving advice on how to get your articles read.

Quote:> > I can't think of any sensible definition of "user space" that
> > describes how threads are implemented in Linux.
> "user space" as I used it, means the user address space, as opposed to
> kernel/supervisor address space. The pthreads library runs in the user
> address space, which means no address space change, or context switch,
> is necessary when calling the pthreads API calls. An important
> performance distinction, that really shows up on uncontested mutex
> calls.
> What terminology would you use to distinguish between the pthreads APIs
> being implemented in a shared object running in the user address space
> and implemented in the kernel via system calls?

What?  We're not talking about libraries, we're talking about
threads.  I see the point you're trying to make, but your distinction
is clearly pedantic in the context of this discussion (which why I
emphasized "sensible").  There is a well-established definition of
user-space in this context, and it doesn't mean what you say it does.

Look at it this way: If the kernel has to be modified to provide
support for the threading library, it's not a user-space threading
library.  The extent or abstraction of the kernel interface isn't
relevant, at least not in this context.  User-space threading
libraries are those which are implemented _entirely_ in user space.

I understand the point you are trying to make, but it seems patently
false to me.  And I suspect you're arguing it out of stubbornness
rather than out of any particular belief.  I suppose I should've
accused you of sophistry instead of pedantry in that case, but I guess
they both apply.

--

"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj

 
 
 

kernel thread VS user space thread in linux

Post by Norman Blac » Wed, 27 Mar 2002 05:50:06





> > > Please put your reply below the quoted text, as I have done.

> > Fashion police?

> No, just giving advice on how to get your articles read.

It's never been a problem.

Quote:> I understand the point you are trying to make, but it seems patently
> false to me.  And I suspect you're arguing it out of stubbornness
> rather than out of any particular belief.  I suppose I should've
> accused you of sophistry instead of pedantry in that case, but I guess
> they both apply.

Wow

--
Norman Black
Stony Brook Software
nospam => stonybrk




> > > Please put your reply below the quoted text, as I have done.

> > Fashion police?

> No, just giving advice on how to get your articles read.

> > > I can't think of any sensible definition of "user space" that
> > > describes how threads are implemented in Linux.

> > "user space" as I used it, means the user address space, as opposed
to
> > kernel/supervisor address space. The pthreads library runs in the
user
> > address space, which means no address space change, or context
switch,
> > is necessary when calling the pthreads API calls. An important
> > performance distinction, that really shows up on uncontested mutex
> > calls.
> > What terminology would you use to distinguish between the pthreads
APIs
> > being implemented in a shared object running in the user address
space
> > and implemented in the kernel via system calls?

> What?  We're not talking about libraries, we're talking about
> threads.  I see the point you're trying to make, but your distinction
> is clearly pedantic in the context of this discussion (which why I
> emphasized "sensible").  There is a well-established definition of
> user-space in this context, and it doesn't mean what you say it does.

> Look at it this way: If the kernel has to be modified to provide
> support for the threading library, it's not a user-space threading
> library.  The extent or abstraction of the kernel interface isn't
> relevant, at least not in this context.  User-space threading
> libraries are those which are implemented _entirely_ in user space.

> I understand the point you are trying to make, but it seems patently
> false to me.  And I suspect you're arguing it out of stubbornness
> rather than out of any particular belief.  I suppose I should've
> accused you of sophistry instead of pedantry in that case, but I guess
> they both apply.

> --

> "Last I checked, it wasn't the power cord for the Clue Generator that
> was sticking up your ass." - John Novak, rasfwrj

 
 
 

kernel thread VS user space thread in linux

Post by Eric P. McC » Wed, 27 Mar 2002 06:49:35



> > > > Please put your reply below the quoted text, as I have done.
> > > Fashion police?
> > No, just giving advice on how to get your articles read.
> It's never been a problem.

I'm tired of fighting.  From now on, anyone who posts illegibly is
getting killfiled.  I'm not obligated to read your posts or reply to
them, and if it takes me more time to reformat them so as to be
readable than it does to reply, I'm just not going to bother.

Quote:> > I understand the point you are trying to make, but it seems patently
> > false to me.  And I suspect you're arguing it out of stubbornness
> > rather than out of any particular belief.  I suppose I should've
> > accused you of sophistry instead of pedantry in that case, but I guess
> > they both apply.
> Wow

OK, then.  From glibc's LinuxThreads README:

  LinuxThreads provides kernel-level threads: each thread is a separate
  Unix process, sharing its address space with the other threads through
  the new system call clone(). Scheduling between threads is handled by
  the kernel scheduler, just like scheduling between Unix processes.

Do you understand now why I think you're being pedantic?

--

"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj

 
 
 

1. threads packages: kernel threads vs. user threads

Hello,

There seem to be other C or C++ language compatible thread packages
besides the standard POSIX 1003.1-2001 thread-related system calls.
For instance Qt implements some thread class code. I would imagine
that implementations which use kernel threads as opposed to user
threads would be based on the POSIX calls. Is this correct? What
other thread packages are available besides the POSIX ones? Just
speculating. Which packages are kernel thread based and which
ones are user thread based?

Thank you for your feedback,

Neil

2. X doesn't work on mac clone ?

3. kernel Thread VS user-level thread

4. /usr/sbin/pppd does not exist or is not executable

5. Synchronizing user space threads with kernel space in linux

6. sendmail and NIS managed aliases problem

7. HELP: communication interface between kernel thread and user thread.

8. VCD or MPEG 2

9. Threads in linux versus threads in NT and threads in Solaris.

10. NT thread vs Linux thread...

11. Linux kernel scheduling of kernel-space thread - question

12. Linux kernel scheduling of kernel-space threads - question