ANONYMOUS wrote:
> 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;