public void load(PCB job) { Console.WriteLine("cpu.loading job: " + job.getJobNumber()); jobNumber = job.getJobNumber(); printFlags("PRE LOADING"); // int instructionCounter = 1; jobMemoryStartAddress = job.getJobMemoryAddress(); start = DateTimeOffset.Now.ToUnixTimeMilliseconds(); j = job; IOCount = 0; tempBuffer = j.getTemporaryBuffer(); inputBuffer = j.getInputBuffer(); outputBuffer = j.getOutputBuffer(); jobCounter = j.getJobInstructionCount(); cacheSize = tempBuffer + inputBuffer + outputBuffer + jobCounter; cache = new String[cacheSize]; instructionCache = new String[jobCounter]; VMA = job.getAllocatedVirtualPages(); for (int i = 0; i < cacheSize; i++) { cache[i] = read(i); } programCounter = j.getProgramCounter(); setIdleFlag(false); setTerminateFlag(false); setJobLoaded(true); Console.WriteLine("cpu.loading jon: " + job.getJobNumber() + " complete"); updateMetrics(CPUMetrics.CPU_STATE.LOADING, "N/A"); sleep(3); updateOsMetrics(); printFlags("POST LOADING"); }
private int calculateChunkSize(PCB pcb, int currentDiskAddress) { int dataCardSize = pcb.getInputBuffer() + pcb.getOutputBuffer() + pcb.getTemporaryBuffer(); int memory = pcb.getJobInstructionCount() + dataCardSize; if (currentDiskAddress + RAM.getPageSize() > pcb.getJobDiskAddress() + memory) { return((pcb.getJobDiskAddress() + memory) - currentDiskAddress); } else { return(RAM.getPageSize()); } }