Esempio n. 1
0
        /**********************************************************************
         *********************************************************************/
        void B_Restart_Clicked(object sender, EventArgs e)
        {
            SequenceList = new List <int>(OrigSequenceList);

            ram  = new int[SequenceList.Count, ramSize, 6];
            disc = new int[SequenceList.Count, discSize];

            currentStep      = -1; //no page in ram or disc yet
            currentPage      = -1;
            indexCurrentPage = -1;
            sequenceLength   = SequenceList.Count();
            pagesInRam       = new List <int>();
            pagesInDisc      = new List <int>();

            draw = new PageReplacementStrategiesDraw(ramSize, discSize, sequenceLength, SequenceList);
            CreateContent();

            //enable/disable buttons
            b_Set_Mbit.IsEnabled    = false;
            b_Reset_Rbits.IsEnabled = false;
            b_Set_Rbit.IsEnabled    = false;

            b_Next.IsEnabled    = true;
            b_Restart.IsEnabled = false;

            InitializeDisc(disc);
            InitializeRam(ram);
        }
Esempio n. 2
0
 /**********************************************************************
  *********************************************************************/
 void CreateTopHalf(Grid grid)
 {
     skiaview = new SKCanvasView();
     skiaview = PageReplacementStrategiesDraw.ReturnCanvas();
     skiaview.BackgroundColor = App._viewBackground;
     grid.Children.Add(skiaview, 0, 0);
 }
Esempio n. 3
0
 /**********************************************************************
  *********************************************************************/
 void B_Set_Mbit_Clicked(object sender, EventArgs e)
 {
     if (currentStep > -1)
     {
         //set m-bit of current page
         ram[currentStep, indexCurrentPage, 2] = 1;
         ram[currentStep, 0, 5] = 1;
     }
     PageReplacementStrategiesDraw.Paint();//Update Canvas
 }
Esempio n. 4
0
        //METHODS

        /**********************************************************************
         *********************************************************************/
        void B_Set_Rbit_Clicked(object sender, EventArgs e)
        {
            if (currentStep > -1)
            {
                //Set r-bit of current page
                ram[currentStep, indexCurrentPage, 1] = 1;
                //ram[currentStep, 0, 4] = 1;
                PageReplacementStrategiesDraw.Paint();//Update Canvas
            }
        }
Esempio n. 5
0
        //CONSTRUCTOR
        public PageReplacementStrategies(List <int> l, String s, int r, int d)
        {
            ToolbarItem info = new ToolbarItem();

            info.Text = App._sHelpInfoHint;
            this.ToolbarItems.Add(info);
            info.Clicked += B_Info_Clicked;

            OrigSequenceList = new List <int>(l);
            SequenceList     = l;

            strategy = s;
            ramSize  = r;
            discSize = d;

            //Ram array explanation
            //[step, ram , 0] = pagenumber (range 0-9, -1 -> no page)
            //[step, ram , 1] = r-bit (0 -> not set, 1 -> set)
            //[step, ram , 2] = m-bit (0 -> not set, 1 -> set)
            //[step, ram , 3] = pagefail (0 -> no pagefail, 1 -> pagefail without replacement, 2 -> pagefail with replacement)
            //[step, ram , 4] = r bits were reset in this step -> 1, else -> 0
            //[step, ram , 5] = m bit was set in this step -> 1, else -> 0
            ram  = new int[SequenceList.Count, ramSize, 6];
            disc = new int[SequenceList.Count, discSize];

            currentStep      = -1; //no page in ram or disc yet
            currentPage      = -1;
            indexCurrentPage = -1;
            sequenceLength   = SequenceList.Count();
            pagesInRam       = new List <int>();
            pagesInDisc      = new List <int>();

            draw = new PageReplacementStrategiesDraw(ramSize, discSize, sequenceLength, SequenceList);

            Title = "Page Replacement Strategies: " + strategy; //since the name is longer than average,
            //the button ahead will automatically be named "back" instead of "Betriebssysteme"
            CreateContent();

            //enable/disable buttons
            b_Set_Mbit.IsEnabled    = false;
            b_Reset_Rbits.IsEnabled = false;
            b_Set_Rbit.IsEnabled    = false;
            b_Next.IsEnabled        = true;

            // content starts only after notch
            On <iOS>().SetUseSafeArea(true);

            InitializeDisc(disc);
            InitializeRam(ram);
        }
Esempio n. 6
0
 /**********************************************************************
  *********************************************************************/
 void B_Reset_Rbits_Clicked(object sender, EventArgs e)
 {
     if (currentStep > -1)
     {
         //reset all r-bits of current step in ram
         for (int j = 0; j <= ram.GetUpperBound(1); j++)
         {
             if (ram[currentStep, j, 1] == 1)
             {
                 ram[currentStep, j, 1] = 0; //r-bit reset
                 ram[currentStep, j, 4] = 1; //mark r-bit as reset
             }
         }
         PageReplacementStrategiesDraw.Paint();//Update Canvas
     }
 }
Esempio n. 7
0
        /**********************************************************************
         *********************************************************************/
        void B_Next_Clicked(object sender, EventArgs e)
        {
            currentStep++;
            currentPage = SequenceList.First();
            SequenceList.Remove(SequenceList.First());
            switch (strategy)
            {
            case "Optimal Strategy":
                Optimal();
                break;

            case "FIFO":
                Fifo();
                break;

            case "FIFO Second Chance":
                FifoSecond();
                break;

            case "RNU FIFO":
                Rnu();
                b_Reset_Rbits.IsEnabled = true;
                b_Set_Rbit.IsEnabled    = true;
                b_Set_Mbit.IsEnabled    = true;
                break;

            case "RNU FIFO Second Chance":
                RnuSecond();
                b_Reset_Rbits.IsEnabled = true;
                b_Set_Rbit.IsEnabled    = true;
                b_Set_Mbit.IsEnabled    = true;
                break;
            }
            PageReplacementStrategiesDraw.Paint();//Update Canvas
            b_Restart.IsEnabled = true;


            //disable next button if the sequence was processed entirely
            if (currentStep == sequenceLength - 1)
            {
                b_Next.IsEnabled = false;
            }
        }