public void loadThisProcess(Process p) { Console.WriteLine("cpu get a process named " + p.getName()); currentProcess = p; currentProcess.setTimeInQueue(); count = 0; idle = false; newTimer.Enabled = true; setBusy(); Program.newGui.addLabelToGuiPanel(p.getName(), processCount); processCount++; }
public void perfomeCPU() { while (true) { lock (Program.o) { if (!isIdle()) { if (currentProcess.getIORequiredTimesQueue().Count() > 0) { if (currentProcess.getIORequiredTimesQueue().ElementAt(0) <= currentProcess.getProcessedTime() + count) { if (currentProcess.getThreadEnabled()) { currentProcess.getIORequiredTimesQueue().RemoveAt(0); Process thread = new Process(currentProcess.getName() + " t", currentProcess.getPriority(), currentProcess.getMeasuredTime(), currentProcess.getSize(), 0, true, true); Program.os.runningToBlockedHandler(thread); Program.newIOHandler.addToIOWaitingProcessesQueue(thread); } else { newTimer.Enabled = false; Console.WriteLine("Blocked"); Program.os.runningToBlockedHandler(currentProcess); currentProcess.setProcessedTime(currentProcess.getProcessedTime() + count); count = 0; Program.newIOHandler.addToIOWaitingProcessesQueue(currentProcess); setIdle(); } } else { if (currentProcess.getProcessedTime() + count >= currentProcess.getMeasuredTime()) { newTimer.Enabled = false; Program.finishedProcesses.addProcess(currentProcess); Program.agingHandler.removeProcess(currentProcess); currentProcess.setProcessedTime(currentProcess.getProcessedTime() + count); Console.WriteLine("process finished and processed time = " + currentProcess.getProcessedTime()); count = 0; setIdle(); } else if (count >= cPUBreakTimeIntervel) { newTimer.Enabled = false; Console.WriteLine("time out****************************************** process getout processed time = " + currentProcess.getProcessedTime()); currentProcess.setProcessedTime(currentProcess.getProcessedTime() + count); count = 0; Program.os.runningToReadyHandler(); setIdle(); } } } else { if (currentProcess.getProcessedTime() + count >= currentProcess.getMeasuredTime()) { newTimer.Enabled = false; Console.WriteLine("finished process"); Program.finishedProcesses.addProcess(currentProcess); currentProcess.setProcessedTime(currentProcess.getProcessedTime() + count); count = 0; setIdle(); } else if (count >= cPUBreakTimeIntervel) { currentProcess.setProcessedTime(currentProcess.getProcessedTime() + count); Console.WriteLine("time out******************************************process getout processed time = " + currentProcess.getProcessedTime()); newTimer.Enabled = false; count = 0; Program.os.runningToReadyHandler(); setIdle(); } } if (newTimer.Enabled == false) { currentProcess.setTimeInQueue(); setIdle(); } } } } }