Total memory for page tables & Number of pages (from the movie The Social Network)

303 Views Asked by At

After watching the movie The Social Network (2010), I'm working on that Harvard sample question which seems to have inspired the scriptwriter. I just wanted to refresh my memory about Computer Architecture.

A sample problem: Suppose we are given a computer with a 16-bit virtual addresses, and a page size of 256 bytes. The system uses one-level page tables, which start at address 0x0400. (The first few pages are reserved for hardware flags, etc. Maybe you wanted to have DMA on your 16-bit system, who knows?) Assume page table entries have eight status bits: 1 valid bit, 1 modify bit, 1 reference bit, and 5 permissions bits (this is a very secure system). How many pages are there? How much memory do the page tables require?

Sadly, I find myself not fully confident about my own answer. I think the physical memory space is 2^16 - 2^10 (when you exclude the memory space up to 0x0400), and so the number of pages should be 252 (=(2^16 - 2^10) / 256). Given the size of each physical memory entry as big as two bytes (8 bits for PPN + 8 bits for page offset), the page table should take up 504 bytes (252 entries x 2 bytes).

Am I still missing something here?

1

There are 1 best solutions below

0
On

Given the surrounding text, I think "reserved" means not usable for regular user-space, i.e. reserved for MMIO addresses. Not that software can't touch it at all.

So you'd want to be able to map any physical page address to a virtual address (so your OS can read/write those hardware flags).

So you'd actually want all 256 PTEs, instead of biasing your page-table indexing by subtracting 3 from the virtual page number.

But then yes, 2-byte PTE (page table entries) consisting of 8 flag bits and 8 page-frame (physical page) page-number bits, and you need 256 of them. (The high 8 bits of a virtual address, i.e. virtual page number, can have 256 values).