views:

77

answers:

2

Hi guys,

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! :)

+3  A: 

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.

Chris Dodd
Thanks very much! :)
Dylan Lin
I worked on a large mainframe in the 70' and 80's that was word addressed. They offered an option that added hardware that allowed you to address bytes or BCD characters directly.
dbasnett
@dbasnett: I hate to break it to you, but the 70s were more than 30 years ago...
Chris Dodd
Just confirming your point.
dbasnett
+1  A: 

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

Mark Ransom