$ make grade running lazytests: (3.7s) lazy: pte printout: OK lazy: map: OK lazy: unmap: OK usertests: (95.8s) usertests: pgbug: OK usertests: sbrkbugs: OK usertests: argptest: OK usertests: sbrkmuch: OK usertests: sbrkfail: OK usertests: sbrkarg: OK usertests: stacktest: OK usertests: all tests: OK Score: 100/100
voidprintwalk(pagetable_t pagetable, int depth) { // there are 2^9 = 512 PTEs in a page table. for (int i = 0; i < 512; i++) { pte_t pte = pagetable[i];
if (pte & PTE_V) { for (int j = 0; j < depth; j++) printf(" .."); // printf("%d: pte %p pa %p %s%s%s\n", i, pte, PTE2PA(pte), (pte) & PTE_R ? "r" : "-", (pte) & PTE_W ? "w" : "-", (pte) & PTE_X ? "x" : "-"); printf("%d: pte %p pa %p\n", i, pte, PTE2PA(pte)); }
if ((pte & PTE_V) && (pte & (PTE_R | PTE_W | PTE_X)) == 0) { // this PTE points to a lower-level page table. uint64 child = PTE2PA(pte); printwalk((pagetable_t)child, depth + 1); } } }
char *mem = kalloc(); if(mem == 0) { // printf("usertrap(): page fault: no more physical page available, killing process due to a OOM\n"); p->killed = 1; goto end; }