Page replacement

I'm implementing a couple different page replacement algorithms (FIFO and LRU) but I'm not sure what the best way to keep track of what pages I currently have in memory. I was thinking just stick them in an array, and replace a given frame when need be, but that doesn't really do anything in regards as to which one was used last.
By memory, you mean in physically addressable memory, right? In that case, you would usually have a page table (basically an array) for each process that tells you where in physical memory (which page frame) their virtual pages are mapped to. In the entries, you could also include additional information like a timestamp of the most recent access.
Well right now I have a frame struct that keeps track of the page reference for that frame, time that reference entered the table, and last time it was referenced.

But the table is usually just implemented as an array?
Yeah, your table would just be an array of those structs. You might make it so the virtual page number is the index into the array for speed reasons, but that isn't strictly necessary.
I guess I am just going at this the wrong way. This program is getting so incredibly messy right now, and I'm not sure how to fix this.
Topic archived. No new replies allowed.