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

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

 



Hi

I have a question I could not find the answer (a clear answer,
atleast) to online or in books.
Before the questions, here is my understanding of process/thread
address spaces and the stack pointers, please tell me if  I am wrong
somewhere.

1) A process has it's own address space and a fork() provides a new
address space to the child (maybe COW). Since a process binary has a
text, data, bss and stack space, the child get's a copy of only the
text portion of the parent. Am I right in assuming this?

2) A thread (inside a process) has it's own stack but it shares the
rest of the segments (text, bss and data) with the parent, is this
right?

3) A thread stack is created INSIDE the address space of the parents
stack. For example, if a parent's break_value is at 0x60000000 and
it's stack pointer is at 0x80000000, then if we create another thread,
it's stack will be somewhere between the break_value and stack pointer
(i.e., end of parent's stack space) of the parent?

4) During a context/process switch, the stack pointer is popped from
the registers. Where does it go (stored on the hard disk?), and which
registers are popped from the stack? What about all the OTHER values
in the address space?

For example, I am executing process-A and it has a timeslice on the
CPU. After it's expired, process-B takes over. Process A must be
having a lot of variables the values of which must be stored in the
address space of process-A. Now, if we store only the stack pointers
and a few other register values, where do we get the whole lot of
variable values from when we reinstate process-A into the CPU?  For
example, how does the CPU know about the "text" segment or let's say
the data segment?

If the text and data segments are also stored as a "snapshot" into
some place, how does the CPU know which process's snapshot is stored
where?

5) In linux VM, all processes think they have the whole range of
physical memory at their disposal. Can two processes (A and B) have a
mapping to the "same" physical address? They are not sharing memory,
btw. Or is it that if a process is not sharing memory, every one of
it's pages will have to have a different address in the physical space
(different from all the page frames of ALL other processes).?

Thank you for your time, 
-- 
-
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