public void MEC(Process process) throws IOException { process.setState("Running"); int clock = 0; // while loop to execute instructions while (clock <= process.getRemainingTime()) { clock++; if (isTermenated()) { // if the process terminates, then break the method process.setState("Terminated"); RAM.loadProcessFromHardDisk(); return; } if (isInterrupted(process)) { // if the process interrupted, then return the process to the Ready Queue (RAM) process.setState("Ready"); process.setRemainingTime(process.getRemainingTime() - clock); RAM.returnProcess(process); return; } } // if the process not in the IOBoundJob Queue, then enter it to CPUBoundJob if (!IOBoundJob.isExist(process)) { CPUBoundJob.enqueue(process, 0); } // the CPU finished executing the process Statistic.NUMBER_OF_EXECUTED_PROCESSES++; process.setState("Terminated"); file.writeProcess(process); RAM.loadProcessFromHardDisk(); }