
CS485G Spring 2015 57
(d) Actually, instead of 2
20
entries, the table is in two layers, but we
ignore that detail for simplicity.
(e) Adjacent addresses within a virtual page all map to the same
page frame in physical memory.
5. MMU algorithm
(a) Separate the virtual address into higher 20 bits (page number)
and lower 12 bits (offset).
(b) Use the page number as an index into the page table.
(c) If the page is missing, generate a page fault trap.
(d) If the CPU has no access permission to the page or the CPU
wants to write and the page is read/execute only, generate an
invalid access fault.
(e) Build a physical address from the page frame (left-shifted 12)
plus the offset.
(f) Success is called a page hit.
6. Lecture 32, 4/20/2015
7. The kernel must deal with page faults.
(a) Some are program errors: attempt to access unallocated mem-
ory. The kernel sends the process a SIGSEGV signal, which typ-
ically terminates the process.
(b) Some are attempts to grow the stack. The kernel allocates more
stack and re-runs the failed instruction.
(c) Some are valid accesses, but the needed virtual page is not in
memory. The kernel allocates a free page frame, brings the vir-
tual page into memory (from backing store, typically disk), then
re-runs the failed instruction.
8. In order to make room for incoming pages, the kernel swaps out
currently unused pages.
(a) There are various algorithms for deciding which page to swap
out. Let’s call it the victim page.
(b) The hope is that the victim is a page that will not be needed
soon.
Comentarios a estos manuales