



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions for cpu scheduling and demand paging problems from cs 162 midterm exam held in spring 2000 at university of california, berkeley. It includes answers for fifo scheduling, shortest job finish scheduling, and min policy, as well as justification for different time-quantum sizes in mfqs approach. Demand paging problems cover lru and fifo page replacement policies, and the optimal policy.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




General Information: This is a closed book examination. You have 1 hour and 20 minutes to answer as many questions as possible. Partial credit will be given. There are 100 points in all. You should read all of the questions before starting the exam, as some of the questions are substantially more time-consuming than others.
Write all of your answers directly on this paper. Be sure to clearly indicate your final answer for each question. Also, be sure to state any assumptions that you are making in your answers.
Please try to be as concise as possible.
Problem Possible Score
a) (4 points) Assume that 3 processes all with requirements of 1 second of CPU time each and no I/O arrive at the same time. What will be the average response time (i.e., average time to completion) for the processes under FIFO scheduling?
ANSWER: 2 seconds, no partial credit
b) (4 points) Answer part "a" for Round Robin (RR) scheduling assuming a timeslice of 0.1 sec and no overhead for context switches (i.e., context switches are free).
ANSWER: 2.9 seconds, no partial credit
c) (4 points) Answer part "a" for Shortest Job Finish (SJF) scheduling.
ANSWER: 2 seconds, no partial credit
d) (4 points) Multilevel Feedback Queue Scheduling (MFQS) is a fairly good, general CPU scheduling algorithm, but as initially described in class, can lead to starvation under certain circumstances. Briefly describe how starvation can occur using MFQS and how to modify MFQS so that starvation can be avoided.
ANSWER: Long jobs on low-priority queues can starve if a continuous stream of short jobs keep the high-priority queues full. Soln: hold a lottery among the QUEUES, weighted in favor of short queues OR implement aging, so that jobs that remain on low-priority queues for a long time are promoted.
CS 162, Spring 2000 (April 10, 2000) SOLUTIONS Midterm #2 Prof. Michael J. Franklin 1
2 pts for starvation explanation 2 pts for correct solution
e) (4 points) What advantage is there in having different time-quantum (i.e. timeslice) sizes on different levels of the MFQS approach?
ANSWER:
a) (3 points) Consider a demand paging system that use 4 KByte pages. In such a system, does a Least Recently Used (LRU) page replacement policy exploring temporal locality? If so, then how? If not, why not?
ANSWER: Yes, LRU keeps recently used pages in memory and temporal locality says that these pages are likely to be accessed in the near future. 1 point for yes + 2 points for a good justification (-1 point for a flaky or waffling answer).
b) (3 points) Consider a demand paging system that use 4 KByte pages. In such a system, does a Least Recently Used (LRU) page replacement policy exploit spatial locality? If so, then how? If not, why not?
ANSWER: Yes. It exploits temporal locality within a page by bringing in 4KBytes at a time and keeping the most recently accessed page in memory. Temporal locality says that other bytes in that page are likely to be accessed in the near future. (grading note: not all replacement policies support temporal locality even if large pages are used--for example, MRU does not exploit it.) 1 point for yes + 2 points for a good justification (-1 point for a flaky or waffling answer).
c) (6 points) Consider a demand paging system with four physical memory frames and the following reference string over seven pages: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6 Assuming that memory starts empty, how many page faults will occur and what will be the final contents of memory under the FIFO page replacement policy? Circle your answers.
ANSWER: 1,3,6,7 in memory and 11 page faults 3 points for right memory contents and 3 points for right fault count. -2 if made a simple mistake in one of these, -3 or -4 if additional simple mistakes. -1 or -2 if you didn't follow directions and made have [sic] to hunt for your answer.
d) (6 points) Answer the problem of part "c" for the LRU policy. Recall that the reference string is: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6. Circle your answers.
ANSWER: 2,3,6,7 in memory and 9 page faults
Problem #1 [5 parts, 20 points total]: CPU Scheduling 2
2 points for incorrect solution (e.g. forgot L_Earth is required regardless of hit or miss) 0 otherwise
b) (6 points) Add the moon -- Now consider the case where the pasta may also be located on the moon (according to the probabilities and miss penalties shown above). In this case, how long should it take for the Alien to find his pasta (assuming he goes from Earth to the Moon, and then to Pluto if necessary)?
ANSWER: Ave. Access Time = L_Earth + (1 - P_Earth) [L_Moon + (1 - P_Moon)(L_Pluto)] = 10 + (1 - 0.2)[100 + (1 - 0.5)(2000)] = 890 minutes 6 points for correct solution 5 points for correct formula but incorrect numerical answer 2 points for incorrect solution (e.g. forgot L_Earth is required regardless of hit or miss) 0 otherwise
c) (8 points) For the problem in part "b" above, for what values (if any) of LMoon would it make sense for the Alien to skip searching the moon and go straight to Pluto?
ANSWER: The alien should skip the moon if the part from part b is larger than the answer from part a. That is: L_earth + (1 - P_Earth)[L_Moon + (1 - P_Moon)(L_Pluto)] > 1610 10 + (1 - 0.2) [L_Moon + (1 - 0.5)(2000)] > 1610 L_Moon > 1000 minutes 8 points for correct solution -2 if you forgot or made an error with the > or >= sign -2 if you clearly set up the problem correctly but got the answer wrong due to error from previous part -6 if you didn't set up the problem correctly -2 if you solved for P_Moon instead of L_Moon
a) (5 points) Suppose we have a 40-bit virtual address separated into an x-bit virtual page number and (40 - x) -bit page offset. Using basic single page table scheme, what is the maximum number of entries in the page table and what is the size of each page (in bytes)?
ANSWER: 2^x page table entries (2 points) 2^(40-x) bytes per page (3 points) 1 point for saying 2^(40-x) page table entries and 2^x bytes per page
b) (5 points) Briefly describe what an Inverted Page Table is. List one advantage and one disadvantage of Inverted tables compared to traditional page tables.
1 point for identifying that the inverted page table translates virtual page numbers for physical page numbers. 1 point for acknowledging the importance of the process ID in looking up entries in an inverted page table. 1 point for recalling that a hash table or other secondary index is always used to make look-ups more
Problem #3 [3 parts, 20 points total]: Caching -- Hungry Aliens Revisited 4
efficient. 1 point for identifying a valid advantage (e.g. fixed table size, global, never needs to be paged, handles sparse address spaces well). fast is NOT an advantage, because inverted page tables are being compared to traditional page tables, which are faster. 1 point for identifying a valid disadvantage (e.g. slower, complex, difficult to implement in hardware, harder to map multiple virtual pages to a single physical page, need additional per-process tables, synchronization problems of using a global page table).
c) (10 points) Consider an architecture combining segmentation and page with 32-bit addresses divided into fields as follows: 4-bit seg id 12 bit page number 16 bit offset into page
SegID Page Table Ptr Page Table Size 0 0x20000 0x 1 0x30000 0x 2 Not Valid ----- 3 0x10000 0x 4 Not Valid ----- ... Not Valid ----- 15 Not Valid -----
Given the contents of physical memory shown on the left [bottom in the case of this html file] and the segment table above, what is the physical address do the following virtual addresses map to (if a virtual address is invalid, stat why) (2 points a piece): 0x00001234 = 0x100001234 = 0x11111234 = 0x20021234 = 0x30031234 =
Address Value 0x10000 0x 0xA 0xB 0x ... ... 0x20000 0x 0x 0x 0x ... ... 0x30000 0x 0x 0x 0x
Problem #4 [3 parts, 20 points total]: Address Translation 5
2 pts for a valid problem with large files
Posted by HKN (Electrical Engineering and Computer Science Honor Society) University of California at Berkeley If y 7