Re: Process, Lightweight Process and Thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Daniel...

Here comes my thoughts....

On Sat, Jan 16, 2010 at 8:24 AM, Daniel (Youngwhan) Song
<breadncup@xxxxxxxxx> 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

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux