Exemplo n.º 1
0
        public void ChooseAlgorithm()
        {
            Console.WriteLine("Wybierz algorytm: ");
            Console.WriteLine("1. Przydział równy\n2. Przydział proporcjonalny\n3. Sterowanie częstością błędów strony\n4. Model strefowy");
            switch (int.Parse(Console.ReadLine()))
            {
            case 1:
                algorithm = new PR(clonedList, frameList.Count);
                break;

            case 2:
                algorithm = new PP(clonedList, frameList.Count);
                break;

            case 3:
                algorithm = new SCBS(clonedList, frameList.Count);
                break;

            case 4:
                algorithm = new MS(clonedList, frameList.Count);
                break;

            default:
                newAlgorithm = false;
                break;
            }
        }
Exemplo n.º 2
0
        public void ChooseAlgorithm()
        {
            Console.WriteLine("Wybierz algorytm: ");
            Console.WriteLine("1. FIFO\n2. OPT\n3. LRU\n4. A_LRU\n5. RAND");
            switch (int.Parse(Console.ReadLine()))
            {
            case 1:
                algorithm = new FIFO();
                break;

            case 2:
                algorithm = new OPT();
                break;

            case 3:
                algorithm = new LRU();
                break;

            case 4:
                algorithm = new A_LRU();
                break;

            case 5:
                algorithm = new RAND();
                break;

            default:
                x = false;
                break;
            }
        }
Exemplo n.º 3
0
 public Procedure(AlgorithmInterface algorithm, List <Frame> framesList, List <Proces> procesList)
 {
     this.framesList = framesList;
     while (procesList.Count > 0)
     {
         foreach (Proces proces in procesList)
         {
             CheckSpace(proces);
             IncreaseWaitingForRef();
             breaking = false;
             CheckFrames(proces);
             if (!breaking)
             {
                 ErrorOccurred(proces);
             }
             if (proces.ReferenceList.Count <= 0)
             {
                 foreach (Frame frame in proces.OcupiedFrames)
                 {
                     frame.ProcesID = null;
                 }
                 procesesToRemove.Add(proces);
             }
         }
         foreach (Proces proces in procesesToRemove)
         {
             procesList.Remove(proces);
         }
         procesesToRemove.Clear();
         if (procesList.Count > 0)
         {
             algorithm.Refresh(procesList);
         }
     }
     Clean(framesList);
 }
 public Procedure(AlgorithmInterface algorithm, List <Page> pagesList, List <Frame> framesList, List <Reference> referencesList)
 {
     while (referencesList.Count > 0)
     {
         foreach (Page page in pagesList)
         {
             if (page.LogicalLocation == referencesList[0].LogicalLocation)
             {
                 foreach (Frame frame in framesList)
                 {
                     if (frame.PageInside != null)
                     {
                         frame.PageInside.WaitingForRef++;
                         frame.PageInside.TimeInPhysical++;
                     }
                 }
                 foreach (Frame frame in framesList)
                 {
                     if (frame.PageInside == page)
                     {
                         page.SecondChance  = true;
                         page.WaitingForRef = 0;
                         break;
                     }
                     else if (frame.PageInside == null)
                     {
                         frame.PageInside      = page;
                         page.PhysicalLocation = 1;
                         break;
                     }
                     else
                     {
                         page.SecondChance = false;
                     }
                 }
                 if (page.PhysicalLocation == 0)
                 {
                     Frame frameToSwap = algorithm.Swap(page, referencesList, framesList);
                     frameToSwap.PageInside.TimeInPhysical   = 0;
                     frameToSwap.PageInside.WaitingForRef    = 0;
                     frameToSwap.PageInside.PhysicalLocation = 0;
                     frameToSwap.PageInside.SecondChance     = false;
                     frameToSwap.PageInside = page;
                     frameToSwap.PageInside.SecondChance     = true;
                     frameToSwap.PageInside.PhysicalLocation = 1;
                     numberOfErrors++;
                 }
                 break;
             }
         }
         referencesList.Remove(referencesList[0]);
     }
     foreach (Frame frame in framesList)
     {
         frame.PageInside = null;
     }
     foreach (Page page in pagesList)
     {
         page.TimeInPhysical   = 0;
         page.SecondChance     = false;
         page.PhysicalLocation = 0;
         page.WaitingForRef    = 0;
     }
 }