public memoryManager(List <string> refs, int frames) { this.frames = frames; foreach (string each in refs) { string [] splitter = each.Split(' '); int PID = Convert.ToInt32(splitter[0]); int Page = Convert.ToInt32(splitter[1]); pageRef r = new pageRef(PID, Page); pRefs.Add(r); } }
public void FIFOSim() { List <pageRef> l = new List <pageRef>(); foreach (pageRef each in pRefs) { if (!l.Contains(each)) { fifoPFaults++; if (l.Count < frames) { l.Add(each); } else if (l.Count == frames) { pageRef v = l[0]; foreach (pageRef each1 in l) { if (each1.getCount() > v.getCount()) { v = each1; } } v.resetCount(); l.Remove(v); l.Add(each); } } else { each.resetCount(); } foreach (pageRef incs in l) { incs.incCount(); } } Console.WriteLine(fifoPFaults); }