caching 1. explain why int sum = 0; for (i = 0; i < n; i++) sum += a[i]; has spatial and temporal locality. 2. which is better and why? int i,j; int sum = 0; for (i = 0; i < n; i++) for (j = 0; j < n; j++) sum += a[i][j]; OR int i,j; int sum = 0; for (j = 0; j < n; j++) for (i = 0; i < n; i++) sum += a[i][j]; 3. give an example of stride size 1, stride size 2. virtual memory 0. 2**8, 2**10, 2**12, 2**20, 2**30, 2**32 are what in decimal? What is 0x400 in decimal? what is it in 2**N (what is N)? 1. Suppose a computer has 16-bit virtual addresses, 16-bit physical addresses, a page size of 64 bytes, and two-level page tables, like a pentium. How many bits in the page offset? How many entries in the page table as a whole (we don't know how big the page table entry is by itself): (clue: given a 16 bit address, what is the max memory size (64k), then divide by the page size) 2. a pentium has a 32-bit virtual address range. how big is the page table block itself? draw a picture and explain how the 32 bits are mapped into a real memory address (leave out the translation lookaside buffer) 3. what are the 3 main motivations for virtual memory? 4. what is the latency trade off between: main memory versus cache memory disk memory versus main memory 5. if a page fault occurs (and the reference is valid), what does the os due to the paging tables 6. what are two justifications for v.m. in terms of memory protection? 7. define the following: demand page swapping demand zero copy on write 8. what happens vis-a-vis paging when you malloc 32 megabytes in a process? 9. what role do the translation lookaside buffers play in paging? 10. roughly given an execvp call, what does the OS due about the paging tables for the parent, and for the child? 11. as with #10. what about parent/child and fork? 12. if the page size is 4 megabytes with a 32-bit address space, how would that divide up the 32-bit space? what would the trade-offs of such a system be?