示例#1
0
        /// <summary>
        /// this method creates flags for the operating system scheduler based on selected UI options
        /// </summary>
        /// <returns> a struct containing the selected options or null if an error occurred</returns>
        private SchedulerFlags?CreateSchedulerFlags()
        {
            SchedulerFlags temp = new SchedulerFlags();

            temp.schedulingPolicies = schedulingPolicy;
            if (temp.schedulingPolicies == EnumSchedulingPolicies.ROUND_ROBIN) // if the user selected round robin scheduling
            {
                temp.RR_Priority_Policy = priorityPolicy;
                temp.RR_TimeSlice       = RR_Time_Slice;
                temp.RR_Type            = roundRobinType;
                temp.TimeSliceUnit      = RR_Time_Slice_Unit;
            }
            temp.allowCPUAffinity       = allowCPUAffinity;
            temp.defaultScheduler       = useDefaultScheduler;
            temp.runningWithNoProcesses = runWithNoProcesses;
            temp.usingSingleCPU         = true; //TODO Change this when multiple CPU's are Implemented
            if (!temp.runningWithNoProcesses)   // if the user selected to run the scheduler no processes
            {
                temp.readyQueue   = readyQueue;
                temp.waitingQueue = waitingQueue;
                SimulatorProcess proc = readyQueue.Dequeue();
                if (proc != null)
                {
                    proc.CurrentState = EnumProcessState.RUNNING;
                }
                temp.runningProcess = proc; // populate the queues and set the first processes state to running
            }
            else  // otherwise create a blank queue and set the running process to null
            {
                readyQueue          = new Queue <SimulatorProcess>();
                waitingQueue        = new Queue <SimulatorProcess>();
                temp.runningProcess = null;
            }
            temp.cpuClockSpeed        = CPUClockSpeed;
            temp.issuedLotteryTickets = new List <LotteryTicket>();
            temp.drawnLotteryTickets  = new List <LotteryTicket>();
            temp.core = this;
            return(temp);
        }
示例#2
0
 /// <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);
 }