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
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
----- Original Message ---- From: Mulyadi Santosa <mulyadi.santosa@gmail.com> To: manish honap <manish_honap_vit@yahoo.co.in> Cc: kernelnewbies@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 ?
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
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
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.
participants (4)
-
Dave Hylands -
manish honap -
Mulyadi Santosa -
Prashant Shah