예제 #1
0
        public LoadSharing()
        {
            Name          = "LoadSharing";
            numCores      = 4;
            scheduleQueue = new Queue <Process>();
            cores         = new List <Proccessor>();


            for (int core = 0; core < numCores; core++)
            {
                Proccessor newCore = new Proccessor();
                newCore.endTime = -1;
                newCore.CoreID  = core;
                newCore.free    = true;

                cores.Add(newCore);
            }

            nextOpenCoreTime = 0;
            nextOpenCore     = 0;
        }
예제 #2
0
        public void releaseCore(int core)
        {
            //check for IO as we remove process
            Proccessor currCore = cores[core];

            if (currCore.currProc != null)  //Issue where first proc added causes error to occur
            {
                if (currCore.currProc.remainingEvents.Count() > 0)
                {
                    blockProcess(currCore.currProc);
                }
                else
                {
                    currCore.currProc.completedTime = CPUTime;
                    completedProcesses.Add(currCore.currProc);
                }
                contextSwitch();
            }

            currCore.free = true;

            cores[core] = currCore;
        }
예제 #3
0
        public void addCoreProc(int core)
        {
            //Get process
            currProcess = scheduleQueue.Dequeue();

            //Update process statistics
            if (currProcess.responseTime < 0)
            {
                currProcess.responseTime = CPUTime;
            }

            //Add process to core
            Proccessor currCore = cores[core];

            currCore.currProc = currProcess;

            //Setup end time for CPU
            int burstTime = currProcess.remainingEvents.First.Value;

            currProcess.remainingEvents.RemoveFirst(); //And remove the first node from the queue
            currProcess.completedEvents.Add(burstTime);

            currCore.endTime = CPUTime + burstTime;
            currCore.currProc.totalProcessingTime += burstTime;

            //Assign process
            currCore.currProc = currProcess;
            currCore.free     = false;

            //Update core list with new core values
            cores[core] = currCore;

            if (core == nextOpenCore)
            {
                nextOpenCoreTime = currCore.endTime;
            }
        }