Esempio n. 1
0
        public Core(int cpuId, int coreId, int macroTick, double cf, List <Job> tasks, Dictionary <int, int> separation)
        {
            _cpuId      = cpuId;
            CPUID       = cpuId;
            Id          = coreId;
            ReadyList   = new PriorityQueue <Job>(OrderByDeadline);
            WaitingList = new PriorityQueue <Job>(OrderByRelease);
            Tasks       = new List <Job>();
            Hyperperiod = 1;
            MacroTick   = macroTick;
            Event       = new TaskEvent(this);
            Separation  = new Dictionary <int, int>();
            _CF         = cf;



            foreach (var task in tasks)
            {
                Tasks.Add(task);
                task.SetEnvironment(Id, _CF);
                Utilization += task.Cost;
                Hyperperiod  = (int)Extensions.LeastCommonMultiple(Hyperperiod, task.Period);
            }
            Separation.Clear();
            foreach (var item in separation)
            {
                Separation.Add(item.Key, item.Value);
            }
        }
Esempio n. 2
0
 private int OrderByCycle(TaskEvent te1, TaskEvent te2)
 {
     if (te1.Cycle > te2.Cycle)
     {
         return(1);
     }
     if (te1.Cycle == te2.Cycle)
     {
         return(0);
     }
     return(-1);
 }
Esempio n. 3
0
 public Core(int cpuId, int coreId, int macroTick, double cf)
 {
     _cpuId      = cpuId;
     CPUID       = cpuId;
     Id          = coreId;
     ReadyList   = new PriorityQueue <Job>(OrderByDeadline);
     WaitingList = new PriorityQueue <Job>(OrderByRelease);
     Tasks       = new List <Job>();
     Hyperperiod = 1;
     MacroTick   = macroTick;
     Event       = new TaskEvent(this);
     Separation  = new Dictionary <int, int>();
     _CF         = cf;
 }
Esempio n. 4
0
        /// <summary>
        /// Run the simulation with the parameter indicating if the execution trace should be built.
        /// </summary>
        public void Run(bool debug)
        {
            PriorityQueue <TaskEvent> taskEvents = new PriorityQueue <TaskEvent>(OrderByCycle);

            AssignJobs();
            Initialize();
            Environment.Initialize();
            long hyperperiod = (long)2 * Environment.Hyperperiod;

            hyperperiod = SetHyperperiod(hyperperiod) + Tasks.Max(x => x.Offset);

            Evaluator.Reset();

            foreach (Processor cpu in Environment.Cpus)
            {
                foreach (Core core in cpu.Cores)
                {
                    taskEvents.Enqueue(core.Event);
                }
            }

            while (taskEvents.Count() > 0)
            {
                TaskEvent te = taskEvents.Dequeue();
                // Continue enqueuing events as longs as we are
                // within the hyperperiod, or we have unfinished chains
                //if (te.Cycle < hyperperiod || Evaluator.Continue)

                if (te.Cycle < hyperperiod)
                {
                    te.Trigger(debug);
                    taskEvents.Enqueue(te);
                }
            }
            Fitness = Evaluator.GetScore(Matlab);
        }