Thank you for the information, Mulyadi and askb,

To confirm again,

Since kernel thread by kernel_thread() is created by do_fork() in the
kernel, pthread_create() uses clone() system call which eventually calls
do_fork() in the kernel, and fork() in user space calls eventually do_fork()
as well, all threads/process are manged by task_struct with different
configuration(flags). Is this correct?

If then, is my understanding that the implementation of do_fork() is by NPTL
in linux 2.6 correct?

If so, there is no heavy process in the linux in typical. Right?

Best Regards,
Daniel (Youngwhan) Song



On Fri, Jan 15, 2010 at 8:28 PM, Mulyadi Santosa
<mulyadi.sant...@gmail.com>wrote:

> Hi Daniel...
>
> Here comes my thoughts....
>
> On Sat, Jan 16, 2010 at 8:24 AM, Daniel (Youngwhan) Song
> <breadn...@gmail.com> wrote:
> > 1. It seems that the concept of thread in the linux kernel is lightweight
> > process. Is this right?
>
> Yes. A bit OOT, in Windows, there's a lighter form than thread called
> fiber. But in Linux, thread (NPTL, if we want to be specific) is the
> actualization of LWP.
>
> > 1-1 If it is right, are both kernel thread and user-space thread
> (pthread)
> > lightweight process? Or does the lightweight process mean only to kernel
> > thread?
>
> IMHO, LWP (Light Weight Process) is a concept which can be applied in
> both space. However, there is correlation between user space thread
> and kernel space thread. IIRC, in NPTL, the relationship is 1:1 thus
> one user space thread is running on top of one kernel thread. (sorry
> if I use wrong words, but hopefully you get it)
>
> Other threading implementation could do it differently e.g many user
> space threads inside one thread group are multiplexed on top of one
> kernel space thread
>
> > 2. I guess the instance from fork() is a process in user application, and
> > the instance from pthread_create() is a thread.
>
> Correct
>
> >The former process is heavy
> > weight process having copy-on-write feature and the later thread is
> managed
> > by pthread library handled in user mode. Is this right?
>
> Right, with additionaly note: pthread_create eventually calls clone()
> with CLONE_VM and CLONE_THREAD flags IIRC. fork() calls clone() too
> but without those two flags. So you can say, both essentially some
> similar operations (e.g creating new task structs) but the rest is
> different (one is creating whole address space, the other is not).
>
> > Any help would be appreciated. Thanks,
>
> Hopefully it makes things clearer :)
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>

Reply via email to