Question

In: Computer Science

Consider the following string of page references: 5, 7, 8,9, 7, 3, 7, 4, 9, 3,...

Consider the following string of page references:
5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.
showing the frame allocation for:
a. Optimal
b. LRU (least recently used)
c. FIFO (first-in-first-out)
d. List the total number of page faults for each policy. Count page faults only after all frames
have been initialized.

Solutions

Expert Solution

Note: If required page is not present in RAM then its page fault. If yes then its page hit.

a. Optimal Replacement : In this algorithm, pages are replaced which would not be used for the longest duration of time in the future.

string of page references:

5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.

Let number of page frame be = 3

Initially all slots are empty, so when 5, 7, 8 came they are allocated to the empty slots

5

5

miss page fault=1

7

7
5

miss page fault=2

8

8
7
5

miss page fault=3

9 // check which page will not be used in near future={5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.} i.e either you can replace 5 or 8 because it will not be used in near future

8
7
9

miss page fault=4

7

8
7
9

hit

3 //check which page will not be used in near future={5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.} ie. use can ureplace only 8 as 7 and 9 will be used in future

3
7
9

miss page fault = 5

7

3
7
9

hit

4 ////check which page will not be used in near future={5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.} ie. 9 and 3 will be used in immediate future so replace 7

3
4
9

miss page fault = 6

9

3
4
9

hit

3

3
4
9

hit

7 ////check which page will not be used in near future={5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.} ie. 9 and 3 will be used in immediate future so replace 4

3
7
9

miss page fault= 7

3

3
7
9

hit

9

3
7
9

hit

Total number of page fault (Optimal) = 7

b. LRU (least recently used) : In this algorithm page will be replaced which is least recently used.

string of page references:

5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.

Let number of page frame be = 3

Initially all slots are empty, so when 5, 7, 8 came they are allocated to the empty slots

5

5

miss page fault=1

7

7
5

miss page fault=2

8

8
7
5

miss page fault=3

9 // check which page was least recently used before={5, 7, 8} i.e 5 was least recently used and 8 most recently used so replace 5

8
7
9

miss page fault=4

7

8
7
9

hit

3 /check which page was least recently used before={5, 7, 8,9,7} i.e 8 was least recently used and 9 most recently used so replace 8

3
7
9

miss page fault = 5

7

3
7
9

hit

4 //check which page was least recently used before={5, 7, 8,9,7,3,7} i.e 9 was least recently used and 7 most recently used so replace 9

3
7
4

miss page fault = 6

9 //check which page was least recently used before={5, 7, 8,9,7,3,7,4} i.e 3 was least recently used and 4 most recently used so replace 3

9
7
4

miss page fault = 7

3 //check which page was least recently used before={5, 7, 8,9,7,3,7,4,9} i.e 7 was least recently used and 9 most recently used so replace 7

9
3
4

miss page fault = 8

7 //check which page was least recently used before={5, 7, 8,9,7,3,7,4,9,3} i.e 4 was least recently used and 3 most recently used so replace 4

9
3
7

miss page fault= 9

3

3
7
9

hit

9

3
7
9

hit

Total number of page fault (LRU) = 9

C. FIFO (first-in-first-out) : In this algorithm, the operating system keeps track of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page needs to be replaced, page in the front of the queue is selected.

string of page references:

5, 7, 8,9, 7, 3, 7, 4, 9, 3, 7, 3, 9.

Let number of page frame be 4

Initially all slots are empty, so when 5, 7, 8,9 came they are allocated to the empty slots

5

5

miss page fault=1

7

7
5

miss page fault=2

8

8
7
5

miss page fault=3

9

9
8
7
5

miss page fault=4

7 // it is already in memory so —> page hit

9
8
7
5

hit

3

9
8
7
3

miss page fault=5  

7 // it is already in memory so —> page hit

9
8
7
3

hit

4

9
8
4
3

miss page fault=6

9 // it is already in memory so —> page hit

9
8
4
3

hit

3 // it is already in memory so —> page hit

9
8
4
3

hit

7

9
7
4
3

miss page fault=7

3 // it is already in memory so —> page hit

9
8
4
3

hit

9 // it is already in memory so —> page hit

9
8
4
3

hit

Total number of page fault (FIFO) = 7


Related Solutions

Consider the following page reference string: 0, 1, 2, 3, 1, 0, 4, 5, 1, 0,...
Consider the following page reference string: 0, 1, 2, 3, 1, 0, 4, 5, 1, 0, 1, 2, 6, 5, 2, 1, 0, 1, 2, 5 How many page faults would occur for the following replacement algorithms, assuming one, three, five, and seven frames? Remember that all frames are initially empty, so your first unique pages will cost one fault each. Optimal replacement LRU replacement CLOCK replacement FIFO replacement
The following page-reference string: 1, 2, 4, 3, 2, 5, 4, 2, 4, 2, 1, 3,...
The following page-reference string: 1, 2, 4, 3, 2, 5, 4, 2, 4, 2, 1, 3, 2, 3, 1, 3, 6, 1, 6, 4. Main memory with 3 frames of 1 kilobyte available and they are all initially empty. Complete a figure, similar to Figure 8.14(in the slides or textbook), showing the frame allocation for each of the following page replacement policies: a. Optimal b. Least recently used c. First-in-first-out Then, find the relative performance of each policy with respect...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 input 1 2 3 4 5 6 7 8 9 10 11 12 13 14 result 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Enter the data in L1 and L2 in your TI calculator, find the regression line, and construct a scatterplot with the regression line included. Does a line appear to...
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we...
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we search for the key value 10 in the array using the binary search algorithm, what is the sequence of indices that will be accessed in the array? (Hint: For a sublist between index values low and high, the middle index is calculated using: (low + high) / 2. So you need to show the sequence of indices of the middle index in each pass.)...
credit hours number of students 3 to 5 4 5 to 7 5 7 to 9...
credit hours number of students 3 to 5 4 5 to 7 5 7 to 9 9 9 to 11 4 11 to 13 3 a) Plot the histogram, frequency polygon and cumulative frequency polygon. b) Compute the sample mean, sample variance and sample standard deviation c) estimate the median from cumulative frequency distribution and mode from the histogram. d) is this distribution symmetrical or skewed? e) What percent of the student course load is expected to fall with in...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
Consider the following data set: 3 -5 5 7 9 10 -3 35 2 1 1...
Consider the following data set: 3 -5 5 7 9 10 -3 35 2 1 1 a) Determine by hand (you can use the calculator) the mean, median and mode of this data set. show enough details in your work for it to be clear that you did this work. b) Use MINITAB to obtain the above results for this data set (and only these results). c) By hand clearly determine the 5 number summary for this data set and...
Write a 3-4 page (excluding title page an references page) paper applying a nursing philosophy to...
Write a 3-4 page (excluding title page an references page) paper applying a nursing philosophy to nursing practice. Explanation for grading the reflection paper follows: Grading Components Reflect on what is important to you as an individual and as a nursing student. Think about what you believe and what you value. Develop a paper that includes the following: Personal Values (4 points): Identify three values and beliefs that are important to you personally. Professional Values (4 points): Identify the values...
Consider the following set of vectors in R6 S={[-9 7 -8 3 0 -5], [1 -7...
Consider the following set of vectors in R6 S={[-9 7 -8 3 0 -5], [1 -7 3 2 -8 -8], [-6 -14 1 9 -23 -29], [11 -21 14 1 -16 -11], [8 16 -8 8 10 1], [17 -7 13 -8 8 18] (a) (2 points) Demonstrate that S is not a basis for R6. (b) (4 points) Let H = Span S. Find a basis for H and determine its dimension. (c) (2 points) Determine whether v= [1,1,1,−1,−1,−1]...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write a list comprehension to extract the first column of the matrix [1, 4, 7]. Write another list comprehension to create a vector of twice the square of the middle column.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT