CPSC/ECE 322 – Fall 2013 – Exam 3 1. Define the following terms. (20 pts.) locality of reference (in general) temporal locality (in particular) working set thrashing Locality of reference is the non-uniform memory reference behavior of a program. Temporal locality is the behavior that once a memory object is referenced, it is likely to be referenced again. The working set of a program is the set of pages referenced I the last observation period. Thrashing is when the system is overloaded with paging traffic.
Static relocation/Dynamic relocation. Circle one of S or D. (2 pts. each) 2. SR / DR Historical program load-and-execute approach of 1940s and early 1950s. 3. SR / DR Roll-out/roll-in on IBM computers with static relocation in 1960s. 4. SR / DR Swapping on CDC computers in 1960s with one set of relocation registers (i.e., single segment approach). 5. SR / DR Paging on modern computers. SR, SR, DR, DR
Paging/Segmentation. Circle one or both of P or S, as applies. (3 pts. each) 6. P / S Requires mapping table. 7. P / S Variable length. 8. P / S Needs presence bit in table entry. 9. P / S Needs length field in table entry. 6 - both P and S; 7 - S only; 8 - both P and S; 9 - S only
10. Consider a request for 200 units of memory from the same free list under different placement policies. Identify which block is chosen for these policies. (1.5 pts. each) free list: (A)150 -> (B)250 -> (C)320 -> (D)230 -> (E)260 -> (F)210 a. first fit would choose block ____ b. best fit would choose block ____ c. worst fit would choose block ____ B, F, C
11. What is the access time for main memory? A ballpark value is okay. (4.5 pts.) somewhere in the range of 10 nanoseconds
12. What is the access time for a disk? A ballpark value is okay. (4.5 pts.) somewhere in the range of 10 milliseconds
13. Label the following steps required in processing a page fault in their proper sequential order, 1-6. (9 pts.) ____ Load instruction in process 1 has a page fault. CPU saves information about the fault and context switches to an OS fault handler. ____ OS finds a free page frame or selects which page frame should be replaced, and schedules an I/O operation to bring in the missing page from disk to the selected page frame. OS suspends process 1. ____ I/O completion interrupt for the page-in; OS sets the presence bit in the PTE; and, OS changes process 1 back to ready. ____ OS dispatches to another ready process (e.g., process 2). ____ OS checks the PTE to see if requested access is permitted. Since access is allowed, OS does not terminate process 1. ____ OS eventually dispatches to process 1. Load instruction in process 1 is retried and succeeds.
1, 3, 5, 4, 2, 6
14. What is the relationship, if any, between a TLB miss and a page fault? Explain. (5 pts.) page fault => TLB miss
(as in logic, A=>B does not mean that B=>A)
A missing page will cause both a TLB miss and then a page fault. Thus a page fault always has an immediately preceding TLB miss. However, the TLB cannot map all pages present in memory. Thus, a page that is present in memory may eventually have its TLB entry replaced but still remain in memory. A reference to this page would then have a TLB miss, but there would be no page fault.
15. What does a modified bit in a page table entry mean if it is set to 1? What does it cause the OS to do, if anything? If the OS does perform some action based on the modified bit, when does the action occur? (5.5 pts.) The modified bit being set to 1 indicates the page in memory differs from the page image on disk. A modified page must be written back to the disk. The write back typically occurs when the page is chosen for replacement, but it may also occur when a precleaning policy chooses the page for cleaning (e.g., two-handed clock policy).
16. How does PFF decide to steal pages from one process to give to another? (5 pts.) PFF places processes into three categories: 1. those processes with page fault rates above a high threshold, 2. those with page faults rates between high and low thresholds, and, 3. those with page fault rates below a low threshold. PFF tries to steal pages from processes in the third category to give to processes in the first category, thus trying to empty out the first category. If the first category is non-empty but the third category is empty, then a process is chosen for suspension, and its pages are given to processes in the first category. (PFF does not specify how the suspension choice is made.)
17. Consider a 10-page virtual memory with virtual pages numbered from 0 to 9, 10-word pages with words numbered from 0 to 9, a 4-page physical memory with page frames numbered from 0 to 3. VPN P R W X PFN +-------+---+ 0|0|1|0|0| 0 | 1|1|1|0|1| 2 | 2|1|1|1|0| 1 | 3|0|1|1|0| 0 | 4|1|1|0|0| 0 | 5|0|1|0|0| 0 | ... ... +-------+---+
P R W X
-
presence bit read permission write permission execute permission
0 0 0 0
= = = =
not not not not
present, allowed, allowed, allowed,
1 1 1 1
= = = =
present allowed allowed allowed
PFN - page frame number
Starting each time from this page table, what is the result of these virtual address accesses - give either the physical address or the system action (e.g., page fault or protection violation). (3.5 pts. each) a. inst. fetch 45 b. read 46 c. write 47 d. read 28 protection violation, read at physical address 06, protection violation, read at physical address 18
18. Consider the two-handed clock replacement policy, which uses both the reference and modified bits. Fill in the Reference and modified bit values that cause the listed action. (8 pts.) current ref. mod.
new values ref. mod.
action
____ ____
0 0
skip this page for now, continue search
____ ____
0 1
skip this page for now, continue search
____ ____
0 0
clean the page (i.e., write back), skip this page for now, continue search
____ ____
0 0
replace this page (when any scheduled write back on it is completed), move pointer forward
10 11 01 00
Extra credit. Consider executing another program on the above virtual memory system. Assume that the program starts with physical frames 0-2 empty and a page table in frame 3. Use ascending-frame-number placement and LRU replacement to show a trace of the physical addresses, faults, changes in the page table entries, page frame allocation, and LRU replacement information. (10 points) address virt|phys ---- ----
page fault -----
page table entries | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| |--|--|--|--|--|--|--|--|--|--|
page frames | 0| 1| 2|PT| |--|--|--|--|
LRU order -----
80
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
72
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
91
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
54
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
78
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
43
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
65
____
_____
__ __ __ __ __ __ __ __ __ __
__ __ __
_______
page fault -----
page table entries | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| |--|--|--|--|--|--|--|--|--|--|
address virt|phys ---- ----
page frames | 0| 1| 2|PT| |--|--|--|--|
LRU order -----
80
_00_
__PF_
__ __ __ __ __ __ __ __ _0 __
_8 __ __
_0_____
72
_12_
__PF_
__ __ __ __ __ __ __ _1 _0 __
_8 _7 __
_1,0___
91
_21_
__PF_
__ __ __ __ __ __ __ _1 _0 _2
_8 _7 _9
_2,1,0_
54
_04_
__PF_
__ __ __ __ __ _0 __ _1 __ _2
_5 _7 _9
_0,2,1_
78
_18_
_____
__ __ __ __ __ _0 __ _1 __ _2
_5 _7 _9
_1,0,2_
43
_23_
__PF_
__ __ __ __ _2 _0 __ _1 __ __
_5 _7 _4
_2,1,0_
65
_05_
__PF_
__ __ __ __ _2 __ _0 _1 __ __
_6 _7 _4
_0,2,1_