Пример #1
0
        static void Main(string[] args)
        {
            var program = new Program();
            var fifo = new FifoPRA();
            var opt = new OptPRA();
            var lru = new LruPRA();
            var lruAprox = new LruAproxPRA();
            var rand = new RandPRA();

            Console.WriteLine("Podaj ilość Stron");
            var numberOfPages = Console.ReadLine();
            var iloscStron = Int32.Parse(numberOfPages);

            Console.WriteLine("Podaj ilość ramek:");
            var numberOfFrames = Console.ReadLine();
            var iloscRamek = Int32.Parse(numberOfFrames);

            Console.WriteLine("Podaj ilość odwołań:");
            var numberOfRecalls = Console.ReadLine();
            var iloscOdwolan = Int32.Parse(numberOfRecalls);

            program.losujOdwolania(iloscRamek, iloscStron, iloscOdwolan);

            Console.WriteLine("algorytm FIFO: " + fifo.Simulation(_odwolania, _pamiecOp));
            Console.WriteLine("algorytm OPT: " + opt.Simulation(_odwolania, _pamiecOp));
            Console.WriteLine("algorytm LRU: " + lru.Simulation(_odwolania, _pamiecOp));
            Console.WriteLine("algorytm LRU Aproksymowany: " + lruAprox.Simulation(_odwolania, _pamiecOp));
            Console.WriteLine("algorytm RND: " + rand.Simulation(_odwolania, _pamiecOp));

            Console.ReadKey();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            var program = new Program();

            for (int i = 0; i < 10; i++)
            {
                var lru = new LruPRA();
                _listaProcesow.Add(lru);
                _odwolania.Add(new List<int>());
            }

            Console.WriteLine("Podaj ilość ramek:");
            var numberOfRecalls = Console.ReadLine();
            var iloscRameczek = Int32.Parse(numberOfRecalls);

            var proportional = new ProportionalAlocation();
            var equal = new EqualAlocation();

            program.LosujOdwolania();
            _ramekLista = proportional.CreateOperationMemory(_odwolania,iloscRameczek);
            _ramekLista2 = equal.CreateOperationMemory(_odwolania,iloscRameczek);

            var k = 0;
            foreach (var ramka in _ramekLista)
            {
                program.Initialize(ramka, k);
                k++;
            }
            k=0;
            foreach (var ramka in _ramekLista2)
            {
                program.Initialize2(ramka, k);
                k++;
            }

            var agregat = new LruAgregate();
            var agregat2 = new LruAgregate();
            var equalOdwolania = new List<List<int>>();
            var j = 0;
            foreach (var item in _odwolania)
            {
                equalOdwolania.Add(new List<int>(_odwolania[j]));
                j++;
            }
              var equalProcessList = new List<LruPRA>();
            for (int i = 0; i < 10; i++)
            {
                var lru = new LruPRA();
                equalProcessList.Add(lru);
             }

              var results = agregat.SimulateAll(_odwolania, _pamiecOp, _listaProcesow, 3);
              var results2 = agregat2.SimulateAll(equalOdwolania, _pamiecOp2, equalProcessList, 3);
              Console.WriteLine();
              Console.WriteLine("Proporcjonalny");
            foreach (var result in results)
              {
            Console.WriteLine(result);
              }
            Console.WriteLine();
            Console.WriteLine("Equal");
            foreach (var result2 in results2)
              {
            Console.WriteLine(result2);
              }
            Console.ReadKey();
        }