Hi, can you check if the output below is correct using the LRU eviction method if the RAM is fully occupied?
in.txt
0 0 0 0 0 1 1 2 2 3 3 2 2 1 1
out.txt
99, 99, 99, 99
99, 99, 4, 5
6, 7, 3, 0
1, 2, 99, 99
RAM Contents:
2,3,12; 2,3,12; 3,0,9; 3,0,9; 3,1,10; 3,1,10; 2,2,11; 2,2,11; 1,2,13; 1,2,13; 1,3,14; 1,3,14; 2,0,7; 2,0,7; 2,1,8; 2,1,8
Once all 4 pages of process 0 have been loaded, the 5th page is assumed as page 0 again.
Request 5, Process 0, Page 0 (again)
Page 0 is already in RAM.
Update its last accessed time to 4
Thank you!
Hi, no this this should not be the case. Note that a process will always replace one of its own pages if the RAM is full and there is one available to replace (as local replacement is prioritised over global).
As a result of this, once 1 page of each process is in the RAM and the RAM is full each process will have a consistent number of pages. In this case you would end up with 3 process 0, 2 process 1 pages, 2 process 2 pages and 1 process 3 page.
You are correct that you can update the last access time of the page 0 process 0 after the 5th 0 though.
> Hi, no this this should not be the case. Note that a process will always replace one of its own pages if the RAM is full and there is one available to replace (as local replacement is prioritised over global).
>
> As a result of this, once 1 page of each process is in the RAM and the RAM is full each process will have a consistent number of pages. In this case you would end up with 3 process 0, 2 process 1 pages, 2 process 2 pages and 1 process 3 page.
>
> You are correct that you can update the last access time of the page 0 process 0 after the 5th 0 though.
Noted, I've made the changes. Could you verify if this should be the correct output? Thanks!
in.txt
0 0 0 0 0 1 1 2 2 3 3 2 2 1 1
out.txt
0, 99, 2, 3
99, 99, 4, 5
99, 99, 6, 7
99, 1, 99, 99
RAM Contents:
0,0,4; 0,0,4; 3,1,10; 3,1,10; 0,2,2; 0,2,2; 0,3,3; 0,3,3; 1,2,13; 1,2,13; 1,3,14; 1,3,14; 2,2,11; 2,2,11; 2,3,12; 2,3,12
That looks right to me! Just tested it on my end and I got the same result, so either we are both right are both wrong. I certainly hope it's the former.
Adding to this to show how it'd look if you chose to ignore it instead of pushing
99, 1, 2, 3
99, 99, 4, 5
99, 99, 6, 7
99, 0, 99, 99
3,1,10; 3,1,10; 0,1,1; 0,1,1; 0,2,2; 0,2,2; 0,3,3; 0,3,3; 1,2,13; 1,2,13; 1,3,14; 1,3,14; 2,2,11; 2,2,11; 2,3,12; 2,3,12;
How come it is correct, if the replacement is ignored?
Because in the example in the given input last sequence of numbers are "1 1 2 2 3 3 2 2 1 1" and because of that all the pages of process 0 will definitely be replaced by the new pages of all the other processes right? my input and output is as follows
in.txt
0 0 0 0 0 1 1 2 2 3 3 2 2 1 1
out.txt
Process 0 : 99 99 99 99
Process 1 : 5 99 4 99
Process 2 : 6 7 2 3
Process 3 : 0 1 99 99
0,3,9; 0,3,9; 1,3,10; 1,3,10; 2,2,11; 2,2,11; 3,2,12; 3,2,12; 2,1,13; 2,1,13; 0,1,14; 0,1,14; 0,2,7; 0,2,7; 1,2,8; 1,2,8;
> How come it is correct, if the replacement is ignored?
> Because in the example in the given input last sequence of numbers are "1 1 2 2 3 3 2 2 1 1" and because of that all the pages of process 0 will definitely be replaced by the new pages of all the other processes right? my input and output is as follows
>
> in.txt
>
> 0 0 0 0 0 1 1 2 2 3 3 2 2 1 1
>
> out.txt
>
> Process 0 : 99 99 99 99
> Process 1 : 5 99 4 99
> Process 2 : 6 7 2 3
> Process 3 : 0 1 99 99
> 0,3,9; 0,3,9; 1,3,10; 1,3,10; 2,2,11; 2,2,11; 3,2,12; 3,2,12; 2,1,13; 2,1,13; 0,1,14; 0,1,14; 0,2,7; 0,2,7; 1,2,8; 1,2,8;
This isn't correct because we are using the "Local" Least Recently Used (LRU) algorithm to evict processes. You seem to be using "global".
1. At time 0,1,2,3: 0 0 0 0 is loaded.
2. At time 4: The fifth zero is ignored.
3. At time 5,6,7,8: 1 1 2 2 is loaded. RAM is now full.
4. Since RAM is full we need to evict a process to make room for 3, but no page of 3 is currently on RAM so we need to use "global" LRU instead of "local".
5. At time 9: The first 0 on RAM is evicted and replaced with 3.
6. At time 10: The next 3 is loaded and replaces the other 3 ("local" LRU).
7. At time 11, 12: 2 2 replaces the 2's currently in RAM ("local" LRU).
8. At time 13, 14: 1 1 replaces the 1's currently in RAM ("local" LRU).
so in the end the contents of RAM are:
3,1,10; 3,1,10; 0,1,1; 0,1,1; 0,2,2; 0,2,2; 0,3,3; 0,3,3; 1,2,13; 1,2,13; 1,3,14; 1,3,14; 2,2,11; 2,2,11; 2,3,12; 2,3,12;