private void MakeLRU(out int pageFaultCount, out int timeSpent) { pageFaultCount = 0; timeSpent = 0; foreach (var item in InputAddresses) { bool flag = Arithmetic.MakeLRU(item, out int blockNum); dataGridView_LRU.Invoke(new MethodInvoker (() => UpdateDGV(Models.ArithmeticType.LRU, flag, blockNum))); if (flag) { pageFaultCount++; } int threadSleepTime = ThreadSleepByArithmeticResult(flag); timeSpent += threadSleepTime; AddToolTip2Cells(dataGridView_LRU, Models.ArithmeticType.LRU, flag, blockNum, threadSleepTime); } }
private void MakeOPT(out int pageFaultCount, out int timeSpent) { pageFaultCount = 0; timeSpent = 0; for (int i = 0; i < InputAddresses.Count; i++) { bool flag = Arithmetic.MakeOPT(InputAddresses, i, out int blockNum); dataGridView_OPT.Invoke(new MethodInvoker (() => UpdateDGV(Models.ArithmeticType.OPT, flag, blockNum))); if (flag) { pageFaultCount++; } int threadSleepTime = ThreadSleepByArithmeticResult(flag); timeSpent += threadSleepTime; AddToolTip2Cells(dataGridView_OPT, Models.ArithmeticType.OPT, flag, blockNum, threadSleepTime); } }
private void MakeFIFO(out int pageFaultCount, out int timeSpent) { //缺页次数 pageFaultCount = 0; //使用的时间 timeSpent = 0; foreach (var item in InputAddresses) { //执行算法 bool flag = Arithmetic.MakeFIFO(item, out int blockNum); //更新表格 dataGridView_FIFO.Invoke(new MethodInvoker (() => UpdateDGV(Models.ArithmeticType.FIFO, flag, blockNum))); if (flag) { pageFaultCount++; } int threadSleepTime = ThreadSleepByArithmeticResult(flag); timeSpent += threadSleepTime; AddToolTip2Cells(dataGridView_FIFO, Models.ArithmeticType.FIFO, flag, blockNum, threadSleepTime); } }