16.11.2014 Views

CS 540 - Operating Systems - Test 2 - Name: Date: Friday ...

CS 540 - Operating Systems - Test 2 - Name: Date: Friday ...

CS 540 - Operating Systems - Test 2 - Name: Date: Friday ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part 2: (67 points)<br />

1. (8 pts.) P is a set of processes. R is a set of resources. E is a set of request or assignment edges. The<br />

sets P, R, and E are as follows:<br />

P = {P 1 , P 2 , P 3 }, R = {R 1 , R 2 , R 3 },<br />

E = {P 1 → R 1 , P 1 → R 2 , P 2 → R 2 , P 2 → R 3 , P 3 → R 2 , P 3 → R 3 , R 1 → P 2 , R 2 → P 2 , R 3 → P 1 }.<br />

R 1 has one instance. R 2 has two instances. R 3 has one instances.<br />

(a) Draw the resource-allocation graph.<br />

(b) Is there any deadlock in this situation? Briefly Explain.<br />

Ans:<br />

(a) The resource-allocation graph is shown as follows:<br />

✛✘<br />

✛✘<br />

✛✘<br />

P1<br />

P2<br />

P3<br />

✚✙ ✚✙ ✚✙<br />

◗❳❳2 ❳ ◗◗◗◗◗<br />

❳ ❳❳ ✻◗ ✑<br />

❳ ◗◗◗◗◗◗ ✑<br />

❳❳<br />

❳ ✑<br />

❳❳ ✑<br />

❄✑ ✑✑✑✑✑✑✑✸ ❳ ✑ ❳<br />

◗<br />

❄ ✑<br />

❳ ❳❳<br />

✑✰<br />

❳❄<br />

R1 R2 R3<br />

(b) Consider the resource-allocation graph. There are four cycles in the system:<br />

P1 → R1 → P2 → R3 → P1, P1 → R2 → P2 → R3 → P1, P2 → R2 → P2,<br />

P2 → R3 → P1 → R1 → P2.<br />

P1 cannot finish because P1 needs R1 and R2 but can only acquire R2 while R1 is held by P2.<br />

P2 cannot finish because P2 needs R2 and R3 but can only acquire R2 while R3 is held by P1.<br />

P3 cannot finish because P3 needs R1 and R3 but can only acquire R2 while R3 is held by P1.<br />

P1, P2, and P3 cannot progress. The deadlock occurs.<br />

2. (a) (2 pts.) What is Belady’s anomaly?<br />

(b) (2 pts.) Give two page-replacement algorithms that do not suffer from Belady’s anomaly.<br />

(c) (3 pts.) What is the working set model?<br />

(d) (2 pts.) What is the cause of thrashing?<br />

(e) (2 pts.) How does the system detect thrashing?<br />

Ans:<br />

(a) more page frames might not always have fewer page faults. This is called Belady’s anomaly.<br />

(b) LRU and optimal algorithms suffer from Belady’s anomaly.<br />

(c) Paging systems keep each process. working set in memory before letting the process run. This<br />

approach is called the working set model.<br />

(d) Thrashing is caused by under-allocation of the minimum number of pages read required by a<br />

process, forcing it to continuously page fault.<br />

(e) The system can detect thrashing by evaluating the level of CPU utilization as compared to the<br />

level of multiprogramming.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!