开发者

Why 16-bit address with 12-bit offset results in 4KB page size?

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, o开发者_如何转开发ne 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! :)


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.


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


Because with 12 bit, we can address 2^12=4096 slots. Each slot represents an address which size is 1 byte in byte-addressable memory. Hence the total size is 4096*1=4096 bytes = 4KB.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜