Ejemplo n.º 1
0
        private void QueueSlowInstruction()
        {
            int check = CoreManager.checkSlowCoresAvailability();

            if (check != -1)
            {
                CoreManager.EnqueueFastSlowAt(check, CoreManager.slowInstructions.Dequeue());
                RemoveSlowListViewItem();
            }
            else if (CoreManager.checkFastCoresAvailability() != -1)
            {
                CoreManager.EnqueueFastSlowAt(CoreManager.checkFastCoresAvailability(), CoreManager.slowInstructions.Dequeue());
                RemoveSlowListViewItem();
            }
        }
Ejemplo n.º 2
0
        private void SetPage()
        {
            listViewReport1.Items.Add("Core");
            listViewReport2.Items.Add("Total Execution Time");
            listViewReport3.Items.Add("Total Power Consumption");
            listViewReport4.Items.Add("Processes Executed");

            for (int i = 0; i < CoreManager.TotalCoreNum(); i++)
            {
                listViewReport1.Items.Add((CoreManager.IsFast(i) ? "Fast" : "Slow") + " Core #" + (i + 1 - (!CoreManager.IsFast(i) ? CoreManager.numFast : 0)));
                listViewReport2.Items.Add(CoreManager.GetExecTime(i) + " ms");
                listViewReport3.Items.Add(CoreManager.GetPowerConsumption(i) + " W");
                listViewReport4.Items.Add(CoreManager.GetNumProcs(i));
            }
        }
Ejemplo n.º 3
0
        private void GoToRunningPage()
        {
            RunningPage rp = new RunningPage();

            rp.NumFastCores = cbFastCores.SelectedIndex;
            rp.NumSlowCores = cbSlowCores.SelectedIndex;
            rp.PolicyType   = cbPolicy.SelectedIndex;
            rp.FileName     = fileName;

            CoreManager.numFast = rp.NumFastCores;
            CoreManager.numSlow = rp.NumSlowCores;

            rp.inputIsFast       = CoreManager.typesAreFast[0] = cbInput.SelectedIndex == 0;
            rp.outputIsFast      = CoreManager.typesAreFast[1] = cbOutput.SelectedIndex == 0;
            rp.computationIsFast = CoreManager.typesAreFast[2] = cbComputations.SelectedIndex == 0;
            rp.registerIsFast    = CoreManager.typesAreFast[3] = cbRegister.SelectedIndex == 0;

            rp.percentFast = rp.percentSlow = 0;
            float.TryParse(tBoxp1Fast.Text, out rp.percentFast); // verification: always prefer fast
            float.TryParse(tBoxp1Slow.Text, out rp.percentSlow);
            rp.percentFast = Math.Abs(rp.percentFast);
            rp.percentSlow = Math.Abs(rp.percentSlow);
            if (rp.percentFast > 100 || rp.percentSlow > 100) // handle all possible malarky
            {
                rp.percentFast = 100;
                rp.percentSlow = 0;
            }
            else if (rp.percentFast + rp.percentSlow > 100)
            {
                rp.percentSlow = 100 - rp.percentFast;
            }
            else if (rp.percentFast + rp.percentSlow < 100)
            {
                rp.percentFast = 100 - rp.percentSlow;
            }
            CoreManager.SetRatio((int)rp.percentFast, (int)rp.percentSlow);

            int.TryParse(tBoxP4.Text, out CoreManager.QueueLimit);
            CoreManager.QueueLimit -= 1;

            rp.setPage();

            if (fileName != null)
            {
                NavigationService.Navigate(rp);
            }
        }
Ejemplo n.º 4
0
        private void FastSlowBrother()
        {
            while (CoreManager.fastInstructions.Count > 0 || CoreManager.slowInstructions.Count > 0)
            {
                if (CoreManager.DoFastInstruction() && CoreManager.fastInstructions.Count != 0)
                {
                    QueueFastInstruction();
                }
                else if (CoreManager.slowInstructions.Count > 0)
                {
                    QueueSlowInstruction();
                }
                else if (CoreManager.slowInstructions.Count == 0)
                {
                    QueueFastInstruction();
                }

                Thread.Sleep(400);
            }
        }
Ejemplo n.º 5
0
        private void InitializeCoresAndScheduler() // malarky
        {
            int fastCount = 0;
            int slowCount = 0;

            scheduler = new Scheduler(fileName, policyType);//
            scheduler.listViewInstructions = listViewInstructions;
            scheduler.fastListView         = fastListView;
            scheduler.slowListView         = slowListView;

            CoreManager.InitializeCores(numFastCores, numSlowCores, fileName, policyType, txtInfo);

            for (int i = 0; i < CoreManager.cores.Count; i++)
            {
                ListView lv = new ListView();

                if (CoreManager.IsFast(i))
                {
                    fastCount++;
                    CoreManager.fastCores.Add(CoreManager.cores[i]);
                    CoreManager.cores[i].SetCoreListView(lv, fastCount);
                }
                else
                {
                    slowCount++;
                    CoreManager.slowCores.Add(CoreManager.cores[i]);
                    CoreManager.cores[i].SetCoreListView(lv, slowCount);
                }


                ScrollStackPanel.Children.Add(lv);
            }


            myScrollView.Content = ScrollStackPanel;

            scheduler.Start();

            CoreManager.StartCores();
        }
Ejemplo n.º 6
0
        public void DoScheduling()
        {
            //if (PRS_DEBUG) Console.WriteLine("Scheduler|DoScheduling: please enter a filename:");
            //string s = Console.ReadLine();
            ParseForInstructions(filename);

            while (true)
            {
                Thread.Sleep(2000);
                //Console.WriteLine("Scheduler|DoScheduling: starting to empty my queue.");
                while (totalQueue.Count > 0)
                {
                    Instruction instruction = null;
                    int         index       = -1;

                    switch (policy)
                    {
                    case (int)P_TYPE.LIMITED_QUEUE:     // done
                        for (int i = 0; i < CoreManager.TotalCoreNum(); i++)
                        {
                            if (totalQueue.Count <= 0)
                            {
                                break;
                            }
                            if (CoreManager.GetQueueAmount(i) >= CoreManager.QueueLimit)
                            {
                                continue;
                            }
                            instruction = totalQueue[0];
                            CoreManager.EnqueueAt(i, instruction);
                            totalQueue.RemoveAt(0);
                            listViewInstructions.Dispatcher.Invoke(new Action(() =>
                            {
                                listViewInstructions.Items.RemoveAt(1);
                            }));
                        }
                        break;

                    case (int)P_TYPE.RATIO_BASED:                          // close
                        index       = CoreManager.GetMinPercentageIndex(); // !FIX
                        instruction = totalQueue[0];
                        CoreManager.EnqueueAt(index, instruction);
                        totalQueue.RemoveAt(0);
                        listViewInstructions.Dispatcher.Invoke(new Action(() =>
                        {
                            listViewInstructions.Items.RemoveAt(1);
                        }));
                        break;

                    case (int)P_TYPE.FAST_SLOW_BUFFER:
                        FillFastSlowBuffers();
                        FastSlowBrother();
                        break;

                    case (int)P_TYPE.TYPE_BASED:     // done
                        instruction = totalQueue[0];
                        index       = CoreManager.GetMinOfType(instruction.type);
                        CoreManager.EnqueueAt(index, instruction);
                        totalQueue.RemoveAt(0);
                        listViewInstructions.Dispatcher.Invoke(new Action(() =>
                        {
                            listViewInstructions.Items.RemoveAt(1);
                        }));
                        break;
                    }
                    if (policy != (int)P_TYPE.FAST_SLOW_BUFFER)
                    {
                        Thread.Sleep(800);
                    }
                    // malarky
                }
            }
        }
Ejemplo n.º 7
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     CoreManager.ChangeSpeed(0.1f);
 }