CS4448 - Nguyen Tuan Anh - Homework 2
CS4448 - Nguyen Tuan Anh - Homework 2
Given that main memory is composed of only three page frames for public use, and that a program
requests pages in the following order:
a, c, b, d, a, c, e, a, c, b, d, e
a. Using the FIFO page removal algorithm, indicate the movement of the pages into and out of the
available page frames (called a page trace analysis) indicating each page fault with an asterisk (*).
Then compute the failure and success ratios.
b. Increase the size of memory so it contains four page frames for public use. Using the same page
requests as above and FIFO, do another page trace analysis and compute the failure and success
ratios.
c. What general statement can you make from this example? Explain your answer.
Answer
Main memory has three page frames for public use.
Page requests: a, c, b, d, a, c, e, a, c, b, d, e
With three page frames, there were 8 page faults (*). The failure ratio is 8/12, and the success
ratio is 4/12.
Now, let's repeat the page trace analysis with four page frames.
With four page frames, there were still 4 page faults (*). The failure ratio is 4/12, and the
success ratio is 8/12.
c. General Statement:
The general statement we can make from this example is that increasing the number of
available page frames in main memory can significantly reduce the number of page faults
when using the FIFO (First-In-First-Out) page replacement algorithm. With three page
frames, there were 8 page faults, resulting in a failure ratio of 8/12. However, when the
number of page frames was increased to four, the number of page faults reduced to 4,
resulting in a lower failure ratio of 4/12.
13. Calculate the cache hit ratio using the formula presented in this chapter,
assuming that the total number of requests is 2,056, and 777 of these requests
are found in the cache
Answer
To calculate the cache hit ratio, you can use the following formula:
Cache Hit Ratio = (Number of Cache Hits / Total Number of Requests) * 100%
So, the cache hit ratio is approximately 37.79%. This means that out of 2,056 total requests,
777 were found in the cache, indicating that roughly 37.79% of the requests were satisfied by
the cache without needing to access the main memory or storage.
15. Given three subroutines of 550, 290, and 600 words each, if segmentation is
used, then the total memory needed is the sum of the three sizes (if all three
routines are loaded). However, if paging is used then some storage space is
lost because subroutines rarely fill the last page completely, and this results in
internal fragmentation. Determine the total amount of wasted memory due
to internal fragmentation when the three subroutines are loaded into memory
using each of the following page sizes:
a. 100 words
b. 600 words
c. 700 words
d. 900 words
Answer
Given:
Subroutine 2:
Subroutine 3:
Ex17.
Answer
a/ FIFO meas first in first out so in this page replacement algorism the page frame which was loaded
first will be swapped out
b/ LRO means least recently used and from the given table page frame 2 was the least recently used.
We can say that it is ide from a longer time as compared to others so in LRU page 2 will be swapped
out
c. Page frame 3 will be swapped out by MRO because it has been referenced most recently. We can
know this by seeing the time when last referenced
Ex19
Answer
(a) From the given Segment Map Tables for Job1 and Job2,the following segments which are located
at memory location 2048, 6144 and 9216 are shared by Job1 and Job2.
(b)
Segment Memory
Number Location
0 4096
1 6144
2 9216
3 1024
4 8192
Segment Memory
Number Location
0 1024
1 6144
2 9216