Question

I'm reading the "Modern Operating System" book. And I'm confused about the "Page Size".

In the book, the author says,

The incoming 16-bit virtual address is split into a 4-bit page number and 12-bit offset. With 4 bits for the page number, we can have 16 pages, and with 12 bits for the offset, we can address all 4096 bytes within a page.

Why 4096 bytes? With 12 bits, we can address 4096 entries within a page, correct. But, one entry is an address (in this case, address size = 16 bits). So I think we can address 4096(entry) * 16(bit) = 4096(entry) * 2(byte) = 8KB, but why the book says that we can address 4096 (bytes) ?

Thanks in advance! :)

Was it helpful?

Solution

This is assuming byte-addressed memory (which almost every machine made in the past 30 years uses), so each address refers to a byte, not an entry or address or any other larger value. To hold a 16-bit value, you'll need two consecutive addresses (two bytes).

More than 30 years ago, there used to be machines which were word addressed, which worked like you surmise. But such machines had a tough time dealing with byte-oriented data (such as ASCII characters), and so have fallen out of favor. Nowadays, things like byte addressability, 8-bit bytes and twos-complement integers are pretty much just assumed.

OTHER TIPS

The 12 bits are an offset within a page. The offset is in bytes, not addresses. 2^12 is 4096.

What you are calculating is the page size, i.e. the size of a page in the page table in the memory. As we use 12 bits for the offset, each frame in the physical memory is 2^12=4096K. However, each page in the page table occupies 2^12 entries x 2 bytes = 8K in the memory.

okay so you have 16 bit virtual address let see what does it mean .It means you have 2**16 =65536 bytes.

4 bit page number that means there are 16 pages as 2^4=16 Now You Name The Pages As page1,page2...page16.

Now We are left with 12bits let us see how many address can 12 bits represent 2**12=4096 bytes

65536 bytes could also be achieved by dividing it into 16 pages containing 4096 bytes each as 4096*16=65536

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top