Contents of CR3 register when a kernel thread is executed

Peter Teoh htmldeveloper at gmail.com
Tue Apr 19 08:49:14 EDT 2011


On Mon, Apr 18, 2011 at 9:17 PM, limp <johnkyr83 at hotmail.com> wrote:

> Hi all,
>
> I am trying to understand in what extend the PGD (page global directory)
> value stored in the CR3 register indicate the running process/thread by the
> Linux scheduler.
>



>
> I know that each process has its own PGD value but what I am confused about
> is the value of CR3 register when kernel threads are scheduled.
>
>
yes, each process has its own CR3 value -> u can easily see this when u do a
printk() of it....and it is always equal to the process (which is "insmod"
usually) that started the kernel module.   i experimented it here:

http://www.issociate.de/board/post/492650/Does_cr3_register_change_when_a_new_process_is_scheduled_?.html


> AFAIK, a "kernel thread" can 'borrow' the page-directory that belongs to
> another process (i.e. its address space). Does this apply *only* to threads
>

yes, "borrow" in the sense that:   kernel thread DOES NOT have any process
context, and so it can be executed in any process context, and which ever
process context it is executing, when u print the CR3 value, it will belong
to that process which the kernel thread is currently executing under.

read this:

http://www.scs.ch/~frey/linux/kernelthreads.html


> of the same process (i.e. all the threads of process A are using the PGD
> entry of process A) or could also apply to threads not relevant to process
> A?
>
> That is, if a thread is executed and the value of CR3 at the time is
> 0x1E107000, does this *necessary* mean that a thread of the process with
> PGD
> 0xDE107000 is executed *or* a thread not relevant with that process could
> have 'borrowed' its PGD entry?
>
> Any help will be greatly appreciated.
>
> John K.
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110419/ad7e8808/attachment.html 


More information about the Kernelnewbies mailing list