To help you prepare for your final, the Professor has asked me to put up some sample solutions to certain questions from Chapters 8 and 9 of your textbook Chapter 8 ========= 8.5 : --- Memory: m1=100K, m2=500K, m3=200K, m4=300K,m5=600K Process: p1(212K), p2(417K), p3(112K), p4(426K) First-fit: p1 is placed in m2 p2 is placed in m5; p3 is placed in m2 behind p1; p4 will be placed either in m2 after p1 and p3 finish or in m5 after p2 finishes depending on who finishes first. Best-fit: p1 is placed in m4 p2 is placed in m2 p3 is placed in m3 p4 is placed in m5 Worst fit: p1 is placed in m5 p2 is placed in m2 p3 is placed in m5 behind p1 p4 will be placed in m2 after p2 finishes or in m5 after p1 and p3 finish depending on who finishes first Best-fit algorithm makes most effective use of memory 8.8 : --- Addressing within a 1024 word page requires 10 bits (2^10 =1024). Since the logical address space consists of 8 = 2^3 pages, the logical address must be 10+3=13 bits. Similarly since there are 32=2^5 physical frames, physical address is 10+5=15 bits long. 8.10 : ---- a> A paged memory reference requires 2 memory accesses: one to get the frame number for the page number from memory and actually accessing the data. So if a memory reference takes 200 nanoseconds then a paged memory reference will take 400 nanoseconds. b> If associative registers are added and the hit ratio is 75% then effective memory access time is given as EMAT = 0.75*200 + 0.25*400 = 250 nanoseconds 8.16 : ---- This is basically very simple. The logical addresses for the segments are of the form . Using the number , find the base from the segment table. Then add the offset to the base to get the physical address. a> 0,430 = 219+430 = 649 b> 1,10 = 2300+10 = 2400 d> 3,400 = 1327+400 = 1727. NOTE: Observe I have not solved parts c and d. There is an error in them. What is it??? -------------------------------------------------------------------------------------- Chapter 9 ========= 9.3 : --- Consider the frame size of 4096 bytes. The virtual address 11123456 corresponds to 2716th frame and an offset of 2816 bytes in that frame, in virtual memory. There are only 64 frames in physical memory. When the user process generates a request for this frame, the OS checks in the associative register. If it does not find the frame there, it goes to the page table in main memory to check whether the particular page has already been loaded into main memory. If not,the OS executes a scheduling routine. To bring the page into main memory, the OS replaces a free frame or a victim frame with this frame. Now the address generated corresponds to the 2716th frame in the disk and it has an offset of 2816 within that frame. The corresponding physical address is generated by adding 2816 to the base address corresponding to the frame. 9.5 : --- EAT = (1-p)*Memory Access Time + p*Page Fault Time EAT < 200 ns Memory Access Time is 100 ns. Since we are given that page is to be replaced is modified for 70% of time Page Fault Time is 0.7*20 + 0.3*8 = 16.4 ms 200ns > (1-p)*100ns + p*16.4*10^6 ns ( Note that conversion is to be done) Solving, we get p < 6.098 ns 9.6 : --- Rather than answering the question directly, I am arranging the algorithms in the order of best to worst in terms of page fault rate. Optimal algorithm : Best LRU replacement Optimal replacement FIFO replacement : Worst...also suffers from Belady's anomaly. 9.10 : ---- Assume that int takes 2 bytes a> The number of page faults is 100 * 100 = 1000 b> The number of page faults is 100 * 2 =200 9.11 : ---- I am not going to solve all the sub-parts here. Try it out and if you cant get it, meet me and we can go over it. I am putting down the answers for 4 and 5 frames I have put a dot below the parts of the string where the fault occurs.Also recollect that inital loading generates page faults 4 Frames: LRU : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . . . . 10 faults FIFO : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . . . . . . . . 14 faults Optimal : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . . 8 faults 5 Frames: LRU : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . . 8 faults FIFO : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . . . . 10 faults Optimal : 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6 . . . . . . . 7 faults. --------------------------------------------------------------------------------------