


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
The cs 540 operating systems exam 2, which covers topics such as deadlocks, resource allocation, page replacement algorithms, and virtual memory management. The exam includes multiple-choice questions and requires understanding of concepts related to operating systems and memory management.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



CS 540 - Operating Systems - Test 2 - Name: Date: Friday, November 19, 2004
Part 1: (33 points - 3 points for each problem)
( C ) 1. Which strategy is used in the Banker’s algorithm for dealing with deadlocks? (A) Deadlock Ignorance (B) Deadlock Detection (C) Deadlock Avoidance (D) Deadlock Prevention
( D ) 2. Which deadlock condition does ordering resources numerically attack? (A) Mutual exclusion (B) Hold and wait (C) No preemption (D) None of the above
( B ) 3. Which of the memory allocation schemes are not subject to internal fragmentation? (A) Multiple Contiguous Fixed Partitions (B) Segmentation (C) Paging (D) None of above
( D ) 4. A system has 256 MB memory. The time to read or write a 32-bit memory word is 10 nsec. Assume the total processes take 3 times of memory taken by holes. What is the time needed to eliminate holes by compaction? (A) 167.772 ms (B) 335.544 ms (C) 503.316 ms (D) None of the above
( A ) 5. A computer with physical address space of 2^24 words has the frame size of 4096 (2^12 ) words. If the hexadecimal physical address is 123456, the frame number in hexadecimal would be: (A) 123 (B) 456 (C) 1234 (D) 123456
( D ) 6. If there are 128K pages and the page size is 32K words, the length of logical address is: (A) 24 bits (B) 28 bits (C) 30 bits (D) 32 bits
( C ) 7. A system has 64 virtual pages mapping into 16 physical frames in the following equation: frame number = page number % 16. Each page has 1K words. If the virtual address is 1010101000111101, the physical address would be: (A) 11001000111101 (B) 10101010001111 (C) 10101000111101 (D) None of the above
( A ) 8. A machine with 512 (2^9 ) MB memory has a 32-bit memory word. The frame size is 8 K (2^13 ). words. How many bits are used to indicate the frame number? (A) 14 bits (B) 16 bits (C) 20 bits (D) None of the above
( A ) 9. A system with a 32-bit virtual address. Each page size is 16 KB words. Each table entry takes 4 bytes. What is the size of the page table? (A) 1 MB (B) 2 MB (C) 4 MB (D) 8 MB
( B ) 10. The modified (dirty) bit cannot be used for the purpose of: (A) Implementing NRU page replacement algorithm (B) Dynamic allocation of memory used by one process to another (C) Reducing the average time required to service page faults (D) None of the above.
( D ) 11. Which statement about segmentation is false? (A) There are many linear address spaces. (B) The total address space can exceed the size of physical memory. (C) Sharing of procedures between users is facilitated. (D) None of the above
Part 2: (67 points)
(a) Draw the resource-allocation graph. (b) Is there any deadlock in this situation? Briefly Explain.
Ans:
(a) The resource-allocation graph is shown as follows:
QQs
Qs
Xy
(b) Consider the resource-allocation graph. There are four cycles in the system: P1 → R1 → P2 → R3 → P1, P1 → R2 → P2 → R3 → P1, P2 → R2 → P2, P2 → R3 → P1 → R1 → P2. P1 cannot finish because P1 needs R1 and R2 but can only acquire R2 while R1 is held by P2. P2 cannot finish because P2 needs R2 and R3 but can only acquire R2 while R3 is held by P1. P3 cannot finish because P3 needs R1 and R3 but can only acquire R2 while R3 is held by P1. P1, P2, and P3 cannot progress. The deadlock occurs.
(b) (2 pts.) Give two page-replacement algorithms that do not suffer from Belady’s anomaly. (c) (3 pts.) What is the working set model? (d) (2 pts.) What is the cause of thrashing? (e) (2 pts.) How does the system detect thrashing? Ans:
(a) more page frames might not always have fewer page faults. This is called Belady’s anomaly. (b) LRU and optimal algorithms suffer from Belady’s anomaly. (c) Paging systems keep each process. working set in memory before letting the process run. This approach is called the working set model. (d) Thrashing is caused by under-allocation of the minimum number of pages read required by a process, forcing it to continuously page fault. (e) The system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming.
(a) If the aging algorithm is used with an 8-bit counter, give the values of the counters after the last tick. (b) Which page would be selected to be removed from memory?
Ans:
(a) R bits Page 0 Page 1 Page 2 Page 3 Page 4 11001 10000000 10000000 00000000 00000000 10000000 10110 11000000 01000000 10000000 10000000 01000000 00101 01100000 00100000 11000000 01000000 10100000 00101 00110000 00010000 11100000 00100000 11010000 11000 10011000 10001000 01110000 00010000 01101000 01011 01001100 11000100 00111000 10001000 10110100 10101 10100110 01100010 10011100 01000100 11011010 11001 11010011 10110001 01001110 00100010 11101101 (b) Page 3 has the smallest value. It will be evicted.
Ans:
(a) FIFO - 14
0 2 3 1 4 2 5 6 0 1 3 2 4 7 1 2 0 2 3 1 4 4 5 6 0 1 3 2 4 7 1 1 0 2 3 1 1 4 5 6 0 1 3 2 4 7 7 0 2 3 3 1 4 5 6 0 1 3 2 4 4 0 2 2 3 1 4 5 6 0 1 3 2 2 P P P P P P P P P P P P P P
(b) LRU - 14
0 2 3 1 4 2 5 6 0 1 3 2 4 7 1 2 0 2 3 1 4 2 5 6 0 1 3 2 4 7 1 2 0 2 3 1 4 2 5 6 0 1 3 2 4 7 1 0 2 3 1 4 2 5 6 0 1 3 2 4 7 0 2 3 1 4 2 5 6 0 1 3 2 4 P P P P P P P P P P P P P P
(c) Optimal - 10
0 2 3 1 4 2 5 6 0 1 3 2 4 7 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 4 4 5 6 6 6 3 3 4 7 7 7 1 1 1 1 1 1 1 1 1 1 1 1 1 P P P P P P P P P P