/// <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; }
/// <summary> /// Constructor for process Scheduler /// </summary> /// <param name="flags"> the flags to use to create this scheduler</param> public Scheduler(SchedulerFlags flags) { readyQueue = flags.readyQueue ?? new Queue <SimulatorProcess>(); waitingQueue = flags.waitingQueue ?? new Queue <SimulatorProcess>(); runningProcess = flags.runningProcess; schedulingPolicy = flags.schedulingPolicies; RR_TimeSlice = flags.RR_TimeSlice; timeSliceUnit = flags.TimeSliceUnit; defaultScheduler = flags.defaultScheduler; RR_Priority_Policy = flags.RR_Priority_Policy; RR_Type = flags.RR_Type; usingSingleCPU = flags.usingSingleCPU; allowCPUAffinity = flags.allowCPUAffinity; runningWithNoProcesses = flags.runningWithNoProcesses; cpuClockSpeed = flags.cpuClockSpeed; suspended = false; issuedLotteryTickets = flags.issuedLotteryTickets; drawnLotteryTickets = flags.drawnLotteryTickets; core = flags.core; CollectionChanged += OnCollectionChanged; CreateBackgroundWorker(); //BindingOperations.EnableCollectionSynchronization(readyQueue,thisLock); }
/// <summary> /// Constructor for OS Core that takes flags which control OS behaviour /// </summary> /// <param name="flags"> the flags to be passed to this operating system</param> public OSCore(OSFlags flags) { schedulingPolicy = flags.schedulingPolicy; RR_Time_Slice = flags.RR_Time_Slice; RR_Time_Slice_Unit = flags.RR_Time_Slice_Unit; priorityPolicy = flags.priorityPolicy; roundRobinType = flags.roundRobinType; useDefaultScheduler = flags.useDefaultScheduler; useSingleCPU = flags.useSingleCPU; allowCPUAffinity = flags.allowCPUAffinity; runWithNoProcesses = flags.runWithNoprocesses; CPUClockSpeed = flags.CPUClockSpeed; suspendOnStateChange_Ready = flags.suspendOnStateChange_Ready; suspendOnPreEmption = flags.suspendOnPreEmption; suspendOnStateChange_Running = flags.suspendOnStateChange_Running; suspendOnStateChange_Waiting = flags.suspendOnStateChange_Waiting; forceKill = flags.forceKill; faultKill = flags.faultKill; osState = flags.osState; scheduler = flags.scheduler; readyQueue = new Queue <SimulatorProcess>(); waitingQueue = new Queue <SimulatorProcess>(); CollectionChanged += OnCollectionChanged; }