Example #1
0
 public void LongTermScheduler(int ramStartLocation)
 {
     //Find next process so we can add it to ready queue
     CurrentJob = PCB.GetInstance().getNextProcess().GetProcessId();
     CurretRamLoc = ramStartLocation;
     RamStartLoc = ramStartLocation;
     tempProcessData = PCB.GetInstance().getProcessData(CurrentJob);
     CurrentDiskLoc = tempProcessData.GetProcessDiskStart();
     if (RamStartLoc + tempProcessData.GetProcessCount() + tempProcessData.GetDataDiskSize()
         + tempProcessData.GetOutputBuffer() + tempProcessData.GetInputBuffer()
           + tempProcessData.GetTempBuffer() < 1024)
     {
         ReadyQueue.GetInstance().addJob(CurrentJob);
         PCB.GetInstance().getProcessData(CurrentJob).SetProcessState(ProcessData.PROCESS_READY);
         PCB.GetInstance().getProcessData(CurrentJob).SetProcessMemoryStart(Ram.GetInstance().WriteLocation(
             HardDrive.GetInstance().GetDataFromLocation(CurrentDiskLoc), CurretRamLoc));
         CurretRamLoc++;
         CurrentDiskLoc++;
         InstructionCount = tempProcessData.GetProcessCount();
         //place the rest of the process's in the ram
         while(CurrentDiskLoc < tempProcessData.GetProcessDiskStart() + InstructionCount)
         {
             Ram.GetInstance().Write(HardDrive.GetInstance().GetDataFromLocation(CurrentDiskLoc));
             CurrentDiskLoc++;
             CurretRamLoc++;
         }
         //now move on to data
         CurrentDiskLoc = tempProcessData.GetDataDiskStart();
         PCB.GetInstance().getProcessData(CurrentJob).SetDataMemoryStart(CurretRamLoc);
         int DataCount, DataTempBuffer;
         DataCount = tempProcessData.GetDataDiskSize();
         DataTempBuffer = tempProcessData.GetTempBuffer();
         while (CurrentDiskLoc < (tempProcessData.GetDataDiskStart() + DataCount))
         {
             Ram.GetInstance().Write(HardDrive.GetInstance().GetDataFromLocation(CurrentDiskLoc));
             CurrentDiskLoc++;
             CurretRamLoc++;
         }
         while (DataTempBuffer > 0)
         {
             Ram.GetInstance().Write("0x00000000");
             DataTempBuffer--;
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException("Scheduluer: Ram out of bounds");
     }
 }
Example #2
0
 public void dispatchProcess(int process)
 {
     currentProcess = PCB.GetInstance().getProcessData(process);
     instruction = currentProcess.GetProcessMemoryStart();
     busy = true;
 }
Example #3
0
 private Dispatcher()
 {
     busy = false;
     currentProcess = null;
     instruction = -1;
 }