Re: PAGE_SIZE query

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

 



Right. But It should be always a right shift right? Why your example has a left shift 1 << PAGE_SHIFT?


Thanks for the explanation.
Mrunal

On Mon, Apr 21, 2008 at 12:15 PM, Nikhil Talpallikar <nikhil.talpallikar@xxxxxxxxx> wrote:


On Tue, Apr 22, 2008 at 12:25 AM, Mrunal Gawade <mrunal.gawade@xxxxxxxxx> wrote:
This is in continuation of above query.

Virtual address is = 32 bit - 10 + 10 + 12 bits
10 bits -> Page directory entry offfset
10 bits -> Page table entry offset
12 bits- > Offset of data within page

---------------
I read somewhere that PAGE_SHIFT macro gives the page number of the page. Now if we consider this 32 bit address, and shift of 12 bits to the left how is that justified. I feel confused.

Size of (page) = 4kb ( 2^12 ) (on X86 arch)
32 bit address space available ==  2^32
therefore number of pages (virtually) available == 2^32/2^12 == 2^20 
so we have 2^20 pages  or page numbers  or page addresses available.
now consider we have a 32 bit address XXXX.....
right shift it by 12 bits,  voila! i have the page number.
got it :)


cheers,
Nikhil



[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