Beispiel #1
0
 /// <summary>
 /// Constructor for a process
 /// </summary>
 /// <param name="flags"> the flags to create this process with</param>
 public SimulatorProcess(ProcessFlags flags)
 {
     this.program               = flags.program;
     this.programName           = flags.programName;
     this.processName           = flags.processName;
     this.processPriority       = flags.processPriority;
     this.processMemory         = flags.processMemory;
     this.processLifetime       = flags.processLifetime;
     this.processID             = flags.processID;
     this.CPUID                 = flags.CPUid;
     this.burstTime             = flags.burstTime;
     this.displayProfile        = flags.displayProfile;
     this.parentDiesChildrenDie = flags.parentDiesChildrenDie;
     this.delayedProcess        = flags.delayedProcess;
     this.delayedProcessTime    = flags.delayedProcessTime;
     this.delayTimeUnit         = flags.delayTimeUnit;
     this.parentProcess         = flags.parentProcess;
     if (parentProcess != null)
     {
         parentProcessID = parentProcess.processID;
     }
     else
     {
         parentProcessID = -1;
     }
     this.childProcesses      = flags.childProcesses;
     this.processSwapped      = flags.processSwapped;
     this.currentState        = flags.processState;
     this.previousState       = flags.previousState;
     this.resourceStarved     = flags.resourceStarved;
     this.allocatedResources  = flags.allocatedResources;
     this.requestedResources  = flags.requestedResources;
     this.processControlBlock = flags.processControlBlock;
     this.OSid                = flags.OSid;
     this.clockSpeed          = flags.clockSpeed;
     this.unit                = new ProcessExecutionUnit(this, clockSpeed);
     this.lotteryTickets      = flags.lotteryTickets;
     this.ownsSemaphore       = flags.ownsSemaphore;
     this.waitingForSemaphore = flags.waitingForSemaphore;
 }
Beispiel #2
0
 private void LoadPCB()
 {
     if (runningProcess.ControlBlock != null)
     {
         ProcessControlBlock p = runningProcess.ControlBlock;
         runningProcess.Unit.CurrentIndex = p.SpecialRegisters[0].Value / 4;
         for (int i = 0; i < runningProcess.ControlBlock.Registers.Length; i++)
         {
             string registerName = String.Format("R{0:00}", i);
             Register.FindRegister(registerName).SetRegisterValue(p.Registers[i].Value, p.Registers[i].Type);
         }
         for (int i = 0; i < p.SpecialRegisters.Length; i++)
         {
             int v = 0;
             if (p.SpecialRegisters[i].ValueString != null)
             {
                 if (int.TryParse(p.SpecialRegisters[i].ValueString, out v))
                 {
                     SpecialRegister.FindSpecialRegister(p.SpecialRegisters[i].Name)
                     .SetRegisterValue(p.SpecialRegisters[i].Value, p.SpecialRegisters[i].Type);
                 }
                 else
                 {
                     SpecialRegister.FindSpecialRegister(p.SpecialRegisters[i].Name)
                     .SetRegisterValue(p.SpecialRegisters[i].ValueString, p.SpecialRegisters[i].Type);
                 }
             }
             else
             {
                 SpecialRegister.FindSpecialRegister(p.SpecialRegisters[i].Name)
                 .SetRegisterValue(p.SpecialRegisters[i].Value, p.SpecialRegisters[i].Type);
             }
         }
         runningProcess.ProcessLifetime = p.LifetimeMills;
     }
 }