Re: how does kernel manages stack for threads?

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

 



Thank you very much for your answer. If you don't mind, let me ask you
little bit further.

I can see from the code that stack is being shared by different
threads and what I am curious about is the way kernel manages this.
In other words, if I have two threads sharing the same stack, how does
kernel ensures the validity of the stack for each thread?
In my mind, if there is only one stack for both threads, it is very
possible that one thread ends us returning to the the address that the
other thread was supposed to return.
Could you please explain briefly how this is prevented? Thank you very much.

YEH

On Thu, Sep 24, 2009 at 2:03 AM, askb <askb23@xxxxxxxxx> wrote:
> On Wed, 2009-09-23 at 23:28 -0400, CP YEH wrote:
>
> Hi,
>
> I am just wondering how the kernel manages user space stack for
> different threads.
>
> I tried to follow the code and noticed that if CLONE_VM is specified,
> the kernel simply points mm to parent's mm. I suppose pthread does
> specify CLONE_VM so this true for pthread.
>
>
> In this case, both parent and thread points to the same mm and
> especially same stack and I just can't quite understand how this is
> possible.
> Could anyone give me some insight on this?
>
> Threads are created along side with other flags like - CLONE_VM CLONE_FS
> CLONE_FILES CLONE_SIGHAND for sharing the resources belonging to the same
> address space. Though each thread has its own stack within the process
> address space, the stack is also shared among the other threads. So one
> threads stack could be readable be the other threads.
>
> Thank you very much in advance.
>
> YEH
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
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