CS 111 Scribe Notes: Lecture 14 |
11-18-08 |
a[i] → if (!(i < (unsigned) N)) abort();
|
int f(v) { return tab[v]; }
if tab[v] == FAULT
then page isn't there) or compress the page table and use base-bounds registers.
size_t pmap (size_t vpn) {
size_t hi = vpn >> 10;
size_t lo = vpn & ((1 << 10) - 1);
size_t *lopage = PAGETABLE[hi];
if (lopage == FAULT)
return FAULT;
return lopage[lo];
}
* If this returns FAULT, hardware traps, enters kernel, kernel is told pc address that faulted. Kernel can:
off_t swapmap (proc, vpn) {
return disk address or FAULT;
}
void pfault (va ) {
if (swapmap(current process, va) == FAULT)
kill(current process);
else {
(p, va') = removal_policy();
pa = p->pmap(va');
write pa to disk at swapmap(p, va');
pa->pmap(va') = FAULT;
read pa from disk at swapmap(currentprocess, va);
current process->pmap(va) = pa;
}
}
Gets pid & va for a process that doesn't need to be cached (some pages like the page holding pfault cannot be swapped out!)