CSE 451 Homework Assignment #3 Out: May 11, 2000 Due: May 17, 2000 #1. Describe the fundamental differences between a segmented system and a paged system. SOLUTION: Segments are variable sized, (generally) represent logical portions of the program, and often suffer from severe external fragmentation. Pages are fixed size and are all the same size. #2. Assume we have a system with two processes P1 and P2 sharing a common physical page but not necessarily at the same virtual address. P1 has a variable called X allocated in this shared page and sets X to point to itself. void *X; X = &X; a) What problem(s) can be encountered with scheme if P2 wants to share X with P1? SOLUTION: P2 will have trouble understanding P1's virtual address stored in X. b) (Unrelated to part a) Propose a method where P1 and P2 can share pages at different virtual addresses and still share pointers. SOLUTION: Assuming we are only sharing pointers within the page (e.g., X will never point to another page), we would just store the offset of pointer into the page, rather than the virtual address. Since each process knows this, it can simply add the value of its virtual address for the base of that page to the value stored within. If you want to share among several pages, a pretty nasty solution would entail. #3. In class we discussed how a "modified page writer" process can be used to periodically write out modified pages. A similar scenario can be used to generate zeroed pages. Describe the pro(s) and con(s) of being too aggressive or too timid with making zeroed pages. SOLUTIONS: Pros of being too aggressive: Always have zeroed pages (saves time on allocation), very secure. Cons of being too aggressive: Waste too much time zeroing pages, may zero pages unnecessarily (pages that are going to be overwritten anyway). Pros of being too timid: CPU time is conserved, won't zero pages unncessarily. Cons of being too timid: May not have zeroed pages when allocating.