Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The sequence of memory references with memory addresses from a 490-word program is as follows: 480, 315, 230, 173, 86, 411, 185, 11, 386, 215, 104, 10. Assuming a page size of 100 words and a primary memory capacity of 300 words, what is the number of page faults using the LRU replacement algorithm?

What I have tried:

I could not find the correct answer.
Posted
Updated 5-Nov-23 1:52am
v2
Comments
RedDk 28-Oct-23 13:26pm    
Show code. The reason I say this is that I'm confused about your explanation. Provide a link to "LRU replacement"? That might clear things up but I doubt any operating system keywords will be present there.
Dave Kreskowiak 28-Oct-23 21:16pm    
There is no code. This is a school assignment on theory.
work business 31-Oct-23 1:27am    
If I don't understand the theory how can i go through the code? see guys, nobody is forcing you to reply questions or put comment, if you have knowledge, you help, if you don't have so leave it.let those who are knowledgable such as @ Richard MacCutchan , they help students to learn well.

See LRU replacement algorithm - Google Search[^]

[edit]
My answer is 9 based on the following table: There are 3 physical pages and 5 virtuals, so the following tables show the virtual page loaded into each physical.

Start the loader loads the first three pages into memory thus:
-------------------------------------
:   0 - 099 : 100 - 199 : 200 - 299 : jump to location 480 - page fault -- 1
-------------------------------------
: 400 - 499 : 100 - 199 : 200 - 299 : jump to 315 - page fault ----------- 2
-------------------------------------
: 400 - 499 : 300 - 399 : 200 - 299 : jump to 230 - no page fault
-------------------------------------
: 400 - 499 : 300 - 399 : 200 - 299 : jump to 173 - page fault ----------- 3
-------------------------------------
: 400 - 499 : 100 - 199 : 200 - 299 : jump to 86 - page fault ------------ 4
-------------------------------------
:   0 - 099 : 100 - 199 : 200 - 299 : jump to 411 - page fault ----------- 5 
-------------------------------------
:   0 - 099 : 100 - 199 : 400 - 499 : jump to 185 - no page fault
-------------------------------------
:   0 - 099 : 100 - 199 : 400 - 499 : jump to 11 - no page fault
-------------------------------------
:   0 - 099 : 100 - 199 : 400 - 499 : jump to 386 - page fault ----------- 6
-------------------------------------
:   0 - 099 : 100 - 199 : 300 - 399 : jump to 215 - page fault ----------- 7
-------------------------------------
:   0 - 099 : 200 - 299 : 300 - 399 : jump to 104 - page fault ----------- 8
-------------------------------------
: 100 - 199 : 200 - 299 : 300 - 399 : jump to 10 - page fault ------------ 9 
-------------------------------------
:   0 - 099 : 200 - 299 : 300 - 399 : END
-------------------------------------

[/edit]
 
Share this answer
 
v2
Comments
work business 28-Oct-23 10:42am    
i know that , just my answer became 12 , i wanted to know is it correct?

initially, the memory is empty, and there are no pages in it.

Page 480 is the first reference and is loaded into memory. This results in 1 page fault.

Page 315 is the second reference and is loaded into memory. This results in 2 page faults.

Page 230 is the third reference and is loaded into memory. This results in 3 page faults.

Page 173 is the fourth reference and is loaded into memory. This results in 4 page faults.

Page 86 is the fifth reference and is loaded into memory. This results in 5 page faults.

Page 411 is the sixth reference and is loaded into memory. This results in 6 page faults.

Page 185 is the seventh reference and is loaded into memory. This results in 7 page faults.

Page 11 is the eighth reference and is loaded into memory. This results in 8 page faults.

Page 386 is the ninth reference, but at this point, the memory is full with 300 words. We need to replace a page. According to the LRU algorithm, the least recently used page is replaced, which is page 480. So, loading page 386 results in 9 page faults.

Page 215 is the tenth reference and is loaded into memory. This results in 10 page faults.

Page 104 is the eleventh reference and is loaded into memory. This results in 11 page faults.

Page 10 is the twelfth reference and is loaded into memory. This results in 12 page faults.

So, using the LRU replacement algorithm, the total number of page faults is 12.





Richard MacCutchan 28-Oct-23 10:49am    
If you want ot know if your asnswer is correct then you should ask the person who gave you the question. I do not have access to a LRU simulator so cannot verify it for you.
Greg Utas 28-Oct-23 15:08pm    
I interpret the question to mean that there is virtual memory space with addresses 0 to 489 (490 words) and 3 physical pages that hold 100 words each. Each of the physical pages could hold virtual addresses 0-99, 100-199, 200-299, 300-399, or 400-489. It's not page 480, page 315, and so on that are being accessed, but virtual memory addresses 480, 315, and so on.
Richard MacCutchan 28-Oct-23 16:02pm    
You are correct of course.
Richard MacCutchan 31-Oct-23 4:12am    
Thanks to your comments I did work on a solution, which may (or may not) be correct.
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did. Just posting your homework assignment and saying "I could not find the correct answer" isn't going to get you anywhere.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
work business 28-Oct-23 9:51am    
Definitely after trying a lot to solve this question, I decided to post it. but I did not understand the solution. It is not homework at all. if you can not be helpful, so please don't comment and let those who are sympathetic to come and help others.
OriginalGriff 28-Oct-23 9:58am    
So it's not homework, it just read exactly like a homework / exam question by total coincidence?

If you've "tried a lot to solve it" then you will have workings - lots of them. Add them to "your" question and explain what was wrong with each attempt ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900