public CPU(Driver k, int id) { kernel = k; disk = k.Disk; RAM = k.RAM; RQ = k.ReadyQueue; cpuPCB = new PCB(); cache = new uint[1]; this.id = id; thread = new Thread(new ThreadStart(this.Run)); _suspendEvent = new ManualResetEventSlim(false); thread.Start(); }
void GetProcess() { lock (dispatcherLock) { if (InterruptHandler.ServicedProcessesCount() == 0) { kernel.Dispatcher.DispatchProcess(this); if (currentProcess != null) { cpuPCB._waitingTime.Stop(); cpuPCB.waitingTime = cpuPCB._waitingTime.Elapsed.TotalMilliseconds; Console.WriteLine("Job " + currentProcess.PCB.ProcessID + " (Priority: " + currentProcess.PCB.Priority + " | Instr. Length: " + currentProcess.PCB.InstructionLength + ") spent " + cpuPCB._waitingTime.Elapsed.TotalMilliseconds.ToString() + "ms waiting.\n"); processCounter++; FillInitalCache(); totalElapsedTime.Start(); } } else { currentProcess = InterruptHandler.DequeueProcess(); if (currentProcess != null) { cpuPCB = currentProcess.PCB; } } } }
public Process(PCB pcb) { PCB = pcb; PCB.ProcessID++; }
public static void ProcessMemoryDump(Driver k, PCB pcb) { lock (fileLock) { StreamWriter writer = new StreamWriter(@"C:\Users\Cory\Documents\Visual Studio 2010\Projects\GitProjects\OS-Project\OS_PROJECT\OS_PROJECT\Phase Two Dumps\Process" + pcb.ProcessID + "MemoryDump.txt", false); //Console.WriteLine("Writing process memory to file..."); uint beginning_page = pcb.PageTable.ReturnFirstPage(pcb); uint number_of_pages = pcb.JobLength / 4; uint frame_to_write; for (uint page = beginning_page; page < beginning_page + number_of_pages + 1; page++) { frame_to_write = pcb.PageTable.table[page].Frame; for (uint offset = 0; offset < 4; offset++) { if (frame_to_write < 10) { writer.Write("[00" + frame_to_write + "]"); } else if (frame_to_write < 100) { writer.Write("[0" + frame_to_write + "]"); } else { writer.Write("[" + frame_to_write + "]"); } writer.Write("[" + offset + "]"); if (pcb.PageTable.Lookup(page).InMemory) { writer.Write("[" + SystemCaller.ConvertInputDataToHexstring(MMU.Read((frame_to_write * 4) + offset)) + "]"); } else writer.Write("[0]"); writer.WriteLine(); } } writer.Close(); } }