Implements FIFO, OPT, LRU, and LFU algorithms in C++ to operate demand paging in Virtual Memory. Accepts a reference string via user input and performs demand paging using various algorithms, providing victim frames and faults.
By the way, test.cpp
under source is my test file. just ignore it. ;_;
- change
opt
,lru
,lfu
some logic struction to justify my task.- add test function for above algo.
- general test data:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
.opt
########## Simulating FIFO ##########
----------------------------------------------------------------------------------------------------------
|Reference_string| 7| 0| 1| 2| 0| 3| 0| 4| 2| 3| 0| 3| 2| 1| 2| 0| 1| 7| 0| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
|Physical_Frame_0| 7| 7| 7| 2| 2| 2| 2| 4| 4| 4| 0| 0| 0| 0| 0| 0| 0| 7| 7| 7| | | | | | | | | | |
|Physical_Frame_1| | 0| 0| 0| 0| 3| 3| 3| 2| 2| 2| 2| 2| 1| 1| 1| 1| 1| 0| 0| | | | | | | | | | |
|Physical_Frame_2| | | 1| 1| 1| 1| 0| 0| 0| 3| 3| 3| 3| 3| 2| 2| 2| 2| 2| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Victim_frames | | | | 7| | 0| 1| 2| 3| 0| 4| | | 2| 3| | | 0| 1| 2| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Faults | 1| 2| 3| 4| 4| 5| 6| 7| 8| 9|10|10|10|11|12|12|12|13|14|15| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
End of reference string!
lru
########## Simulating LRU ##########
----------------------------------------------------------------------------------------------------------
|Reference_string| 7| 0| 1| 2| 0| 3| 0| 4| 2| 3| 0| 3| 2| 1| 2| 0| 1| 7| 0| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
|Physical_Frame_0| 7| 7| 7| 2| 2| 2| 2| 4| 2| 2| 2| 2| 2| 2| 2| 2| 2| 7| 7| 7| | | | | | | | | | |
|Physical_Frame_1| | 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 1| 1| 0| 0| 0| 0| 0| | | | | | | | | | |
|Physical_Frame_2| | | 1| 1| 1| 3| 3| 3| 3| 3| 3| 3| 3| 3| 3| 3| 1| 1| 1| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Victim_frames | | | | 7| | 1| | 2| 4| | | | | 0| | 1| 3| 2| | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Faults | 1| 2| 3| 4| 4| 5| 5| 6| 7| 7| 7| 7| 7| 8| 8| 9|10|11|11|11| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
End of reference string!
lfu
########## Simulating LFU ##########
----------------------------------------------------------------------------------------------------------
|Reference_string| 7| 0| 1| 2| 0| 3| 0| 4| 2| 3| 0| 3| 2| 1| 2| 0| 1| 7| 0| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
|Physical_Frame_0| 7| 7| 7| 2| 2| 3| 3| 4| 2| 2| 2| 2| 2| 1| 2| 2| 2| 2| 2| 2| | | | | | | | | | |
|Physical_Frame_1| | 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| | | | | | | | | | |
|Physical_Frame_2| | | 1| 1| 1| 1| 1| 1| 1| 3| 3| 3| 3| 3| 3| 3| 1| 7| 7| 1| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Victim_frames | | | | 7| | 2| | 3| 4| 1| | | | 2| 1| | 3| 1| | 7| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
| Faults | 1| 2| 3| 4| 4| 5| 5| 6| 7| 8| 8| 8| 8| 9|10|10|11|12|12|13| | | | | | | | | | |
----------------------------------------------------------------------------------------------------------
End of reference string!