开发者

confusion regarding thread in linux

开发者 https://www.devze.com 2023-03-12 12:35 出处:网络
I know that there is no special difference between thread and processing linux, except keeping the cr3 register untouched during the thread switch and tlb flush during process switch.

I know that there is no special difference between thread and processing linux, except keeping the cr3 register untouched during the thread switch and tlb flush during process switch.

Since the threads in groud share same address space and as pgd(page table) is n开发者_如何学Pythonot changed meaning whole memory layout is shared, and hence stack space also gets shared, but as per the general definition thread owns its own stack, how is this acheived in linux.

if its like threadA has stack from x-y range, then at the first pagefault occurs and page table is updated, similarly threadB which uses the range u-v, would update the same pagetable. Hence it is possible to mess up the stack of threadB from threadA.

I just want to get the clear picture on this, help me out.Is this the safe implementation of thread?.


That's correct, there is no OS-enforced protection of the stack memory between threads. One thread A can corrupt the stack of another thread B (if thread A knows where in memory to look).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号