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

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

 



Hello...

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

Correct! And IMHO if the "old" page is no longer referenced by another 
process/thread (IIRC, the indicator is "count" property of page 
descriptor), it is given back to the buddy/slab allocator and free to 
be assigned for other purposes

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

I never read about task id before. My understanding so far is, pid is 
unique for all process. For NPTL based threading mechanisme, system 
call like getpid() returns same value for all thread on the same group, 
because it returns tgid (aka task group id), not the pid itself..and 
tgid is same for all thread in the same thread group. 

This conforms to POSIX standard that getpid() (or any system call that 
yields pid of a process) returns same value for all threads on the same 
group


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

No, not on the hard disk....it is stored on RAM, precisely somewhere 
inside kernel memory region

And yes, kernel keeps a list of all process in every state (sleep, 
running, stopped, and so on). This list is called "task list" and again 
it lives on RAM

"How does the kernel know the PID of a process without first having its 
PD (process descriptor)?" I don't think it is possible.... you need to 
grab the task structure first, then you will found out the pid of a 
process. You can prove this by looking on the function 
find_task_by_pid(). There you will realize the "pid" param is actually 
used as a key to query the task list to find the related task_struct.

In other word, it's not enough to know the pid of a process. Eventually 
every action toward a process structure needs to grab the 
task_struct....

> > 2. on COW scenario
>
> You mean "before" the pages are written onto, right?

Yes...that's correct

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

Thanks to you too. This reminds me to keep re-reading all those kernel 
book :))

regards

Mulyadi


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