* Linux kernel thread model
@ 2011-06-16 4:39 manish honap
2011-06-16 5:15 ` Mulyadi Santosa
2011-06-17 5:26 ` Prashant Shah
0 siblings, 2 replies; 6+ messages in thread
From: manish honap @ 2011-06-16 4:39 UTC (permalink / raw)
To: kernelnewbies
Hi all
Can someone please tell me what is the threading model of linux kernel ?
user space thread:kernel thread process - n:1 or m:n or 1:1
thanks and regards
- Manish
^ permalink raw reply [flat|nested] 6+ messages in thread
* Linux kernel thread model
2011-06-16 4:39 Linux kernel thread model manish honap
@ 2011-06-16 5:15 ` Mulyadi Santosa
2011-06-16 7:06 ` manish honap
2011-06-17 5:26 ` Prashant Shah
1 sibling, 1 reply; 6+ messages in thread
From: Mulyadi Santosa @ 2011-06-16 5:15 UTC (permalink / raw)
To: kernelnewbies
On Thu, Jun 16, 2011 at 11:39, manish honap
<manish_honap_vit@yahoo.co.in> wrote:
> Hi all
>
> Can someone please tell me what is the threading model of linux kernel ?
> user space thread:kernel thread process - n:1 or m:n or 1:1
1:1, that is 1 kernel process represent 1 user space thread.... more
about it, google for NPTL paper written by Ulrich Drepper and Ingo
Molnar.
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Linux kernel thread model
2011-06-16 5:15 ` Mulyadi Santosa
@ 2011-06-16 7:06 ` manish honap
2011-06-16 17:37 ` Mulyadi Santosa
0 siblings, 1 reply; 6+ messages in thread
From: manish honap @ 2011-06-16 7:06 UTC (permalink / raw)
To: kernelnewbies
----- Original Message ----
From: Mulyadi Santosa <mulyadi.santosa@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in>
Cc: kernelnewbies at kernelnewbies.org
Sent: Thu, 16 June, 2011 10:45:36 AM
Subject: Re: Linux kernel thread model
On Thu, Jun 16, 2011 at 11:39, manish honap
<manish_honap_vit@yahoo.co.in> wrote:
> Hi all
>
> Can someone please tell me what is the threading model of linux kernel ?
> user space thread:kernel thread process - n:1 or m:n or 1:1
1:1, that is 1 kernel process represent 1 user space thread.... more
about it, google for NPTL paper written by Ulrich Drepper and Ingo
Molnar.
How they understand whether kernel part is scheduled or user part is scheduled ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Linux kernel thread model
2011-06-16 7:06 ` manish honap
@ 2011-06-16 17:37 ` Mulyadi Santosa
2011-06-16 21:54 ` Dave Hylands
0 siblings, 1 reply; 6+ messages in thread
From: Mulyadi Santosa @ 2011-06-16 17:37 UTC (permalink / raw)
To: kernelnewbies
On Thu, Jun 16, 2011 at 14:06, manish honap
<manish_honap_vit@yahoo.co.in> wrote:
> How they understand whether kernel part is scheduled or user part is scheduled ?
not sure if I got your question correctly, but the one that is
scheduled is the process..... 1:1 model means for single
fork()/clone()/pthread_create() in user space, clone() syscall with
various parameters are called in kernel space. Then, we end up
creating single process. This represent that whole single thread.
whether it's currently running in user space or kernel space, that's
up to the code....
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Linux kernel thread model
2011-06-16 17:37 ` Mulyadi Santosa
@ 2011-06-16 21:54 ` Dave Hylands
0 siblings, 0 replies; 6+ messages in thread
From: Dave Hylands @ 2011-06-16 21:54 UTC (permalink / raw)
To: kernelnewbies
Hi Mulyadi,
On Thu, Jun 16, 2011 at 10:37 AM, Mulyadi Santosa
<mulyadi.santosa@gmail.com> wrote:
> On Thu, Jun 16, 2011 at 14:06, manish honap
> <manish_honap_vit@yahoo.co.in> wrote:
>> How they understand whether kernel part is scheduled or user part is scheduled ?
>
> not sure if I got your question correctly, but the one that is
> scheduled is the process..... 1:1 model means for single
> fork()/clone()/pthread_create() in user space, clone() syscall with
> various parameters are called in kernel space. Then, we end up
> creating single process. This represent that whole single thread.
A few clarifications. I like to think of a process as a memory space,
and a thread as a unit of execution.
Many processes have a single thread, but processes can have mutliple
threads as well.
Each thread has a kernel side and a user-mode side. The kernel mode
portion has its own stack which is separate from the user-mode stack,
but you can think of them all together as being a single thread.
You can view all of the processes in the system by using
ls -d /proc/[0-9]*
You can view all of the threads in the system by using
ls -d /proc/[0-9]*/task/*
Due to historical reasons, we have some confusing terminology which is
different between kernel space and user-space.
The numbers under the task directory are called tids in user-space,
but are called pids in kernel space (i.e. current->pid)
The numbers under the proc directory are called pids in user-space,
but are called tgid in kernel space (i.e. current->tgid)
When running in kernel space, the kernel component of the thread runs
(so the kernel thread-stack is used). When running in user-space, the
user component of the thread tuns (so the user-space stack is used).
When scheduling, you're scheduling the thread as a whole, and not the
kernel-side or user-side component.
If you write a driver or loadable module, you can create kernel
threads which have no user-mode portion, but you can't create a
user-mode thread which doesn't have a kernel side component.
kernel mode threads appear to be their own process, which is where my
process=memory space model break down, but for user space it holds.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Linux kernel thread model
2011-06-16 4:39 Linux kernel thread model manish honap
2011-06-16 5:15 ` Mulyadi Santosa
@ 2011-06-17 5:26 ` Prashant Shah
1 sibling, 0 replies; 6+ messages in thread
From: Prashant Shah @ 2011-06-17 5:26 UTC (permalink / raw)
To: kernelnewbies
Hi manish,
On Thu, Jun 16, 2011 at 10:09 AM, manish honap
<manish_honap_vit@yahoo.co.in> wrote:
> Hi all
>
> Can someone please tell me what is the threading model of linux kernel ?
> user space thread:kernel thread process - n:1 or m:n or 1:1
Straight from Linux Kernel Development 3rd Edition book...
In Linux kernel, there is no concept of thread. Linux implements all
threads as standard processes. Thread is just a process that shares
resources with other processes. There are no special data structures
to represent threads. Each thread has its own process descriptor and
appears to kernel as normal process - they just happen to shares
resource such as address space with other processes.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-06-17 5:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-16 4:39 Linux kernel thread model manish honap
2011-06-16 5:15 ` Mulyadi Santosa
2011-06-16 7:06 ` manish honap
2011-06-16 17:37 ` Mulyadi Santosa
2011-06-16 21:54 ` Dave Hylands
2011-06-17 5:26 ` Prashant Shah
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).