Please work out these problems before your next discussion section. The GSIs and IAs will go over these problems during the discussion section.
A machine uses 32-bit addresses with a 3-level page table. The virtual address is divided into 4 parts as follows: 10-bits, 8-bits, 6-bits, and 8-bits, i.e., the first 10-bit are used to index into the first level,etc., and the last 8-bits as offset into the page.
Assume the valid virtual address range is the lowest 256 KB.
If an instruction takes 10nsec and a page fault takes an additional 10 msec, then
Consider the following system and think about how the program structure affects performance. Your assignment is to initialize an array that has 1024 rows and 1024 columns. Page size in your system is 1024 bytes and fits 1 row of the array. Consider the following initialization routine.
Option 1:
for (row = 0; row < 1024; row++) { for(column = 0; column < 1024; column++) { array[row][column] = 0; } }
Option 2:
for (column = 0; column < 1024; column++) { for(row = 0; row < 1024; row++) { array[row][column] = 0; } }
You system has less than 1024 physical pages, array is not in memory, and you use LRU page replacement.
mprotect() is a function that controls how a section of memory may be accessed (see the mprotect manual page for more information).
int mprotect(void *addr, size_t len, int prot)
To check whether the calling procedure invoked mprotect() with addr and len in the arena, one might write:
if (addr < beginArena || addr+len > endArena) { return -1; }Are the above checks sufficient (assuming the arena is contiguous)? If not, how would you remove such a security hole?