Re: Process adress space (during context/process switch) + VM question

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

 



Thank you Tristan, Mulyadi,

> actually given new process address and whole new page tables, but these
> page tables is pointing on the COW'ed physical pages of the parents.

So in other words, when the child writes onto the physical page COW'ed
from the parent, the VM page handler will invalidate that access and
copy the parent's physical page frame into another physical page frame
and update the child's page table to the NEW PFN. Is this OK?

> Are you sure about this Tristan? IMHO every process has a parent, even
> it is a thread created on NPTL environment. Perhaps you got this
> impression since each thread has same pid?

So the task ID of the parent "process" the same as its PID? 

> Every process/thread has distinct stack area, so there won't be any
> overlapping stack area.

I am not clear "where" this stack area is being created. Is the stack
area of the thread (child thread) created WITHIN the stack area of the
parent thread/process with that space allocated just for the childs
usage?

To put it more clearly, every process has it's own page tables mapping
onto physical memory. In its own virtual address space, there is a
place for storing its own stack (among other things such as text, code
etc). Now, when this process creates a child thread, the thread
doesn't have its own address space but it shares all of the address
space of the parent. But this address space does not include the stack
of the parent since the thread has it;s own stack. So, where does this
stack come from? Is it a part of the parent process's own stack that
is now being used exclusively by the child thread?

> You mean, where it is saved so later it can restored? If this is what
> you mean, read about "thread_struct" structure inside the task_struct.
> That's where the Stack pointer of  current running process is saved
> during context switch

And the task_struct of each process is stored on the hard disk, is
that right? Would I be correct in assuming that the kernel has a
pointer to where every process's process descriptor is located/stored
on the hard disk? How does the kernel know the PID of a process
without first having its PD?

> I don't understand about your question "which registers are popped from
> stack?" If what you mean, is there something popped from (kernel?)
> stack, then the answer no...nothing is popped from kernel stack.

So all the kernel variables "Stay" in the kernel stack all the time
and so do their mappings into virtual memory?


> In short, yes...two or more processes can share same physical pages. The
> possibilities are:
> 1. Those processes use the same shared libraries
> 2. on COW scenario

You mean "before" the pages are written onto, right?

Thank you again for the tremendous help, Tristan and Mulyadi.
-
TD

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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