Valid But Not Present

A page table entry carries a valid bit and a present bit, and the hardware treats them differently:

PTE = AccessMemory(PTEAddr)
if (PTE.Valid == False)
    RaiseException(SEGMENTATION_FAULT)
else if (PTE.Present == True)
    TLB_Insert(VPN, PTE.PFN, PTE.ProtectBits); RetryInstruction()
else
    RaiseException(PAGE_FAULT)

A process calls mmap for a 4 GB file on a machine with 8 GB of RAM, then writes one byte in the middle of the mapping. Which description matches what the bits say?

A

The fault is serviced and control resumes at the instruction after the faulting store, so the byte is left unwritten until the next pass through that code.

B

Before the write the entry is valid but not present, so the access raises a page fault, not a segmentation fault. The OS finds a frame, sets present, and retries the faulting instruction. The other million or so pages stay valid and not present, which is why VSZ reads 4 GB while RSS reads one page.

C

Before the write the entry is invalid, so the hardware raises a segmentation fault that the OS reclassifies as a page fault once it checks the mapping table.

D

mmap fills in every entry as present and points each at a zeroed frame, so VSZ and RSS both jump to 4 GB and the write itself never traps.