Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exam 3/Final Review. Exam 3 u Mean adjusted score: 62% ( C ) u Correct multiple choice answers: 1. D 2. B 3. E 4. A 5. E 6. C 7. A 8. B or C 9. E 10.

Similar presentations


Presentation on theme: "Exam 3/Final Review. Exam 3 u Mean adjusted score: 62% ( C ) u Correct multiple choice answers: 1. D 2. B 3. E 4. A 5. E 6. C 7. A 8. B or C 9. E 10."— Presentation transcript:

1 Exam 3/Final Review

2 Exam 3 u Mean adjusted score: 62% ( C ) u Correct multiple choice answers: 1. D 2. B 3. E 4. A 5. E 6. C 7. A 8. B or C 9. E 10. B 11. C

3 Problem 4 u Assume a disk has 100 cylinders labeled 0-99, the read- write head is positioned over cylinder 52 heading toward cylinder 0, accessing data requires 1 time unit, and incoming requests arrive as follows: u What is the order of the requests which will be serviced by time 64 (cylinder of request is given) by the LOOK disk scheduling algorithm? Arrival time 01031455164 Cylinder10262045211

4 Problem 4 0 10 20 30 40 50 60 70 80 90 99 0 10 20 30 40 50 60 70 (52,0) (26,27) (20,34) (10,45) (29,64) Time Cylinder

5 Problem 5 u Assume a disk has 100 cylinders labeled 0-99, the read- write head is positioned over cylinder 21 heading toward cylinder 0, accessing data requires 1 time unit, and pending requests are as follows: 1, 16, 24, 71, 8, 18, 94, 3 (listed in order of arrival). Which disk scheduling algorithm will finish servicing the requests first?  SSTF (break tie by moving toward cylinder 0.)  LOOK  FCFS  C-Scan  None of the above: there is a tie.

6 Problem 5 u SSTF (21 – 18) + 1 Tie between 18 and 24, move to 18 +(18 – 16) + 1 +(16 – 8) + 1 Tie between 8 and 24, move to 8 +(8 – 3) + 1 +(3 – 1) + 1 +(24 – 1) + 1 +(71 – 24) + 1 +(94 – 71) + 1 =121 1162471818943

7 Problem 5 u Look (21 – 18) + 1 +(18 – 16) + 1 +(16 – 8) + 1 +(8 – 3) + 1 +(3 – 1) + 1 Do not go to 0, turn around +(24 – 1) + 1 +(71 – 24) + 1 +(94 – 71) + 1 =121 1162471818943

8 Problem 5 u FCFS (21 – 1) + 1 +(16 – 1) + 1 +(24 – 16) + 1 +(71 – 24) + 1 +(71 – 8) + 1 +(18 – 8) + 1 +(94 – 18) + 1 +(94 – 3) + 1 =336 1162471818943

9 Problem 5 u C-Scan (read/write heading toward zero) (21 – 18) + 1 +(18 – 16) + 1 +(16 – 8) + 1 +(8 – 3) + 1 +(3 – 1) + 1 +(1 – 0) +(99 – 0) +(99 – 94) + 1 +(94 – 71) + 1 +(71 – 24) + 1 +(24 – 1) + 1 =221 1162471818943

10 Final Exam Review u More disk scheduling u Exponential moving average for predicting next burst u Banker’s algorithm

11 SSTF (static) u Assume the R/W heads hold stationary when there is no pending request, and that seek decisions are never reversed on new arrival u What is the total time to service all requests? (28 – 3) + 1 + (16 – 3) +1 + (58–16) + 1 + (98 – 58) + 1 + (98 – 71) + 1 + (71 – 12) + 1 + (56 – 12) + 1 = 256 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556

12 SSTF (static) 312162856587198 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 0 26 83 124 152 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556 40

13 SSTF (static) 312162856587198 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 212 256 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556

14 SSTF (dynamic) u Assume the R/W heads continue moving toward cylinder 50 when there is no pending request, and that seek decisions can be changed dynamically u What is the total time to service all requests? (28 – 3) + 1 + (16 – 3) +1 + (58–16) + 1 + (98 – 58) + 1 + (98 – 71) + 1 + (71 – 48) + (56 – 48 ) + 1 + (56 – 12) + 1 = 229 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556

15 SSTF (dynamic) 312162856587198 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 0 26 83 124 152 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556 40

16 SSTF (dynamic) 312162856587198 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 184 229 Arrival TimeCylinder 03 416 2058 5198 11371 13112 18556

17 Page Replacement

18 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 01350135 11111111

19 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 21352135 10001000

20 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 21352135 11001100

21 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 21452145 10101010

22 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 21452145 10111011

23 Clock page replacement (2 nd chance) u The use bit is shown to the right of the frames u The arrow denotes the position of the clock pointer 0, 1, 3, 5, 2, 1, 4, 5, 0 20452045 01100110

24 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 01350135 100

25 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 01350135 010 110 010

26 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21352135 100 010 110 010

27 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21352135 010 001 011 001

28 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21352135 110 101 011 001

29 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21342134 110 101 011 100

30 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21342134 011 010 001 010

31 LRU approximation (shift bits) u Each ‘c’ denotes a clock shift event u The reference bit and clock bits are shown to the right of the frame 0, 1, 3, 5, c, 3, 2, c, 1, 2, 4, c, 5 21542154 011 010 100 010

32 Banker’s Algorithm

33 Example of Banker’s Algorithm u 5 processes P 0 through P 4 ; 3 resource types A (4 instances), B (5 instances), and C (6 instances). u Snapshot at time T 0 : AllocationMaxAvailable A B CA B C A B C P 0 0 1 03 5 3 1 3 2 P 1 2 0 0 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3

34 Example of Banker’s Algorithm u Is the system currently safe? u Suppose a request for came from P 1. AllocationMaxAvailable A B CA B C A B C P 0 0 1 03 5 3 1 3 2 P 1 2 0 0 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 1 2 2 2 0 1 2 1 1 3 3 1

35 Example of Banker’s Algorithm u Suppose a request for came from P 1  Is the request legal?  Are the resources available? AllocationMaxAvailable A B CA B C A B C P 0 0 1 03 5 3 1 3 2 P 1 2 0 0 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 1 2 2 2 0 1 2 1 1 3 3 1

36 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxAvailable A B CA B C A B C P 0 0 1 03 5 3 0 2 1 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1

37 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 0 2 1 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P1

38 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 3 3 2 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P1

39 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 3 3 4 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P4P3P1P4P3

40 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 3 4 5 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P4P3P0P1P4P3P0

41 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 3 5 5 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P4P3P0P2P1P4P3P0P2

42 Example of Banker’s Algorithm u Suppose a request for came from P 1  Make a hypothetical grant of the resources  Test to see if the state is safe AllocationMaxWork A B CA B C A B C P 0 0 1 03 5 3 4 5 6 P 1 3 1 1 3 2 2 P 2 1 0 1 3 0 2 P 3 0 1 1 2 2 2 P 4 0 0 23 3 3 Need A B C 3 4 3 0 1 1 2 0 1 2 1 1 3 3 1 P1P4P3P0P2P1P4P3P0P2

43 Detection Algorithm 1.Let Work and Finish be vectors of length m and n, respectively Initialize: (a) Work :- Available (b)For i = 1,2, …, n, if Allocation i  0, then Finish[i] := false;otherwise, Finish[i] := true. 2.Find an index i such that both: (a)Finish[i] = false (b)Request i  Work If no such i exists, go to step 4.

44 Detection Algorithm 3.Work := Work + Allocation i Finish[i] := true go to step 2. 4.If Finish[i] = false, for some i, 1  i  n, then the system is in deadlock state. Moreover, if Finish[i] = false, then P i is deadlocked. Algorithm requires an order of m x n 2 operations to detect whether the system is in deadlocked state.

45 Example of Detection Algorithm u Five processes P 0 through P 4 ; three resource types A (7 instances), B (2 instances), and C (6 instances). u Snapshot at time T 0 : AllocationRequestAvailable A B C A B C A B C P 0 0 1 0 0 0 0 0 0 0 P 1 2 0 0 2 0 2 P 2 3 0 30 0 0 P 3 2 1 1 1 0 0 P 4 0 0 2 0 0 2 u Sequence will result in Finish[i] = true for all i.

46 Example (Cont.) u P 2 requests an additional instance of type C. Request A B C P 0 0 0 0 P 1 2 0 1 P 2 0 0 1 P 3 1 0 0 P 4 0 0 2 u State of system?  Can reclaim resources held by process P 0, but insufficient resources to fulfill other processes; requests.  Deadlock exists, consisting of processes P 1, P 2, P 3, and P 4.


Download ppt "Exam 3/Final Review. Exam 3 u Mean adjusted score: 62% ( C ) u Correct multiple choice answers: 1. D 2. B 3. E 4. A 5. E 6. C 7. A 8. B or C 9. E 10."

Similar presentations


Ads by Google