private void choixAlgorithme_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ram = new RamVirtuelle(5);
     systemExploitation = new SystemExploitation();
     diskDur            = new DiskDur(5);
     tablePages         = new List <EntreeTablePage>();
     majTablePage();
     lancer.IsEnabled  = true;
     sauvSuite         = suiteReferences.Text;
     suivant.IsEnabled = true;
     iteration         = 0;
     systemExploitation.creationTablePages(tablePages, 2 * nbPages, ram, diskDur);
     aux.Children.Clear();
     canvas1.Children.Clear();
     afficherRam(ram);
 }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (sequence.Count != 0)
            {
                SystemExploitation tmpOs = new SystemExploitation();
                tmpOs = systemExploitation.Clone();
                List <object> tmp = sequence.Pop();
                systemExploitation = (SystemExploitation)tmp[0];
                ram        = (RamVirtuelle)tmp[1];
                diskDur    = (DiskDur)tmp[2];
                tablePages = (List <EntreeTablePage>)tmp[3];
                requete    = (List <String>)tmp[4];
                sauvSuite  = (String)tmp[5];
                afficherRam(ram);
                champAdressePhysique.Text = "";
                champAux.Text             = "";
                champRam.Text             = "";
                champTPages.Text          = "";
                demande.Text     = "Demande de l'adresse virtuelle: ";
                deroulement.Text = "Nombre de defauts de page: " + systemExploitation.getDefautDePage().ToString();
                switch (choixAlgorithme.SelectedIndex)
                {
                case 0:
                    suppFileLru();
                    if (tmpOs.fileLru.Count == systemExploitation.fileLru.Count && tmpOs.fileLru.Peek() != systemExploitation.fileLru.Peek())
                    {
                        double  y       = 0;
                        Ellipse ellipse = new Ellipse()
                        {
                            Height = 30, Width = 30, Fill = Brushes.Cyan
                        };

                        TextBlock num = new TextBlock
                        {
                            Text = tablePages.FindIndex(h => h.getPageCorrespandante() == systemExploitation.fileLru.Peek() && h.getDisponible() == true).ToString(), FontSize = 14
                        };
                        double x = (aux.Children.Count / 2) * (ellipse.Width + 10);
                        aux.Children.Insert(0, ellipse);
                        Canvas.SetLeft(ellipse, x);
                        Canvas.SetTop(ellipse, y);
                        aux.Children.Insert(1, num);
                        Canvas.SetLeft(num, x + ellipse.Height / 2 - num.FontSize / 2 + 1);
                        Canvas.SetTop(num, y + ellipse.Width / 2 - num.FontSize / 2);
                    }
                    break;

                case 1:
                    foreach (EntreeTablePage page in tablePages)
                    {
                    }
                    //suppFileFifo();
                    //if (tmpOs.fifo.Count == systemExploitation.fifo.Count && tmpOs.fifo.Peek() != systemExploitation.fifo.Peek())
                    //{
                    //    double y = 0;
                    //    Ellipse ellipse = new Ellipse()
                    //    { Height = 30, Width = 30, Fill = Brushes.Cyan };

                    //    TextBlock num = new TextBlock
                    //    { Text = tablePages.FindIndex(h => h.getPageCorrespandante() == systemExploitation.fifo.Peek() && h.getDisponible() == true).ToString(), FontSize = 14 };
                    //    double x =  (aux.Children.Count / 2) * (ellipse.Width + 10);
                    //    aux.Children.Insert(0, ellipse);
                    //    Canvas.SetLeft(ellipse, x);
                    //    Canvas.SetTop(ellipse, y);
                    //    aux.Children.Insert(1, num);
                    //    Canvas.SetLeft(num, x + ellipse.Height / 2 - num.FontSize / 2 + 1);
                    //    Canvas.SetTop(num, y + ellipse.Width / 2 - num.FontSize / 2);
                    //}
                    break;

                case 2:
                    affichLfu();
                    break;

                case 3:
                    affichMatriceAging();
                    break;
                }
                iteration--;
                lancer.IsEnabled  = true;
                suivant.IsEnabled = true;
                majTablePage();
                if (iteration == 0)
                {
                    precedent.IsEnabled = false;
                }
            }
        }
Esempio n. 3
0
        public void gestionRequete(int typeRemplacement, List <EntreeTablePage> tablePages, int numeroPage, RamVirtuelle ram, DiskDur hdd)
        {
            EntreeTablePage entreeTablePage = Mmu.traductionAdresse(tablePages, numeroPage);

            if (entreeTablePage == null)
            {
                // acces page non alloué
            }
            else
            {
                if (entreeTablePage.getDisponible() == false) //defaut de page
                {
                    switch (typeRemplacement)
                    {
                    case 0:
                        rempalcementLru(tablePages, entreeTablePage.getPageCorrespandante(), ram, hdd);
                        fileLru.Enqueue(entreeTablePage.getPageCorrespandante());
                        break;

                    case 1:
                        remplacementFifo(tablePages, entreeTablePage.getPageCorrespandante(), ram, hdd);
                        fifo.Enqueue(entreeTablePage.getPageCorrespandante());
                        break;

                    case 2:
                        remplacementLfu(tablePages, entreeTablePage.getPageCorrespandante(), ram, hdd);
                        lfu.Find(l => l[0] == entreeTablePage.getPageCorrespandante())[1]++;
                        break;

                    case 3:
                        for (int i = 0; i < 5; i++)
                        {
                            aging[i] = aging[i] >> 1;
                        }
                        remplacementAging(tablePages, entreeTablePage.getPageCorrespandante(), ram, hdd);
                        break;
                    }
                    defautDePage++;
                }
                else
                {
                    switch (typeRemplacement)
                    {
                    case 0:
                        fileLru.SkipWhile(r => r == entreeTablePage.getPageCorrespandante());
                        fileLru.Enqueue(entreeTablePage.getPageCorrespandante());
                        break;

                    case 1:
                        break;

                    case 2:
                        lfu.Find(l => l[0] == entreeTablePage.getPageCorrespandante())[1]++;
                        break;

                    case 3:
                        for (int i = 0; i < 5; i++)
                        {
                            aging[i] = aging[i] >> 1;
                        }
                        aging[entreeTablePage.getPageCorrespandante()] += ((uint)(1 << 15));
                        break;
                    }
                    tablePages[numeroPage].setDirty(true);
                }
            }
        }
Esempio n. 4
0
 public void creationTablePages(List <EntreeTablePage> tablePages, int taille, RamVirtuelle ram, DiskDur hdd)
 {
     for (int i = 0; i < taille; i++)
     {
         EntreeTablePage entreeTablePage = new EntreeTablePage();
         entreeTablePage.setPageCorrespandante(23 + hdd.getNombreCases());
         Case cas = new Case(entreeTablePage.getPageCorrespandante());
         hdd.cases.Add(cas);
         hdd.setNombreCases(hdd.getNombreCases() + 1);
         tablePages.Add(entreeTablePage);
     }
 }
Esempio n. 5
0
        public void rempalcementLru(List <EntreeTablePage> tablePages, int adressePhysique, RamVirtuelle ram, DiskDur hdd)
        {
            if (ram.getNombrepagesLibres() == 0) //remplacement
            {
                int             indRam = fileLru.Dequeue();
                EntreeTablePage tmp    = new EntreeTablePage();

                tmp = tablePages.Find(e => e.getPageCorrespandante() == indRam && e.getDisponible() == true);
                tmp.setDisponible(false);
                tmp.setDirty(false);
                int entree = tablePages.FindIndex(x => x.getPageCorrespandante() == adressePhysique);
                tablePages[entree].setDisponible(true);
                tmp.setPageCorrespandante(hdd.tableAuxiliere[indRam]);
                hdd.tableAuxiliere[indRam] = tablePages[entree].getPageCorrespandante();
                tablePages[entree].setPageCorrespandante(indRam);
            }
            else
            {
                int ipage = 0;
                ipage = ram.listPages.FindIndex(p => p.getVide() == true);
                int entree = tablePages.FindIndex(x => x.getPageCorrespandante() == adressePhysique);
                tablePages[entree].setDisponible(true);
                tablePages[entree].setPageCorrespandante(ipage);
                hdd.tableAuxiliere[ipage] = adressePhysique;
                ram.listPages[ipage].setVide(false);
                ram.setNombrePagesLibres(ram.getNombrepagesLibres() - 1);
            }
        }
Esempio n. 6
0
 public void remplacementLfu(List <EntreeTablePage> tablePages, int adressePhysique, RamVirtuelle ram, DiskDur hdd)
 {
     if (ram.getNombrepagesLibres() == 0) //remplacement
     {
         int[]           lf     = lfu.Find(l => l[1] == lfu.Min(f => f[1]));
         int             indRam = lf[0];
         EntreeTablePage tmp    = new EntreeTablePage();
         tmp = tablePages.Find(e => e.getPageCorrespandante() == indRam && e.getDisponible() == true);
         tmp.setDisponible(false);
         tmp.setDirty(false);
         int entree = tablePages.FindIndex(x => x.getPageCorrespandante() == adressePhysique);
         tablePages[entree].setDisponible(true);
         tmp.setPageCorrespandante(hdd.tableAuxiliere[indRam]);
         hdd.tableAuxiliere[indRam] = tablePages[entree].getPageCorrespandante();
         tablePages[entree].setPageCorrespandante(indRam);
         lfu.Remove(lf);
         lfu.Add(new int[] { indRam, 0 });
     }
     else
     {
         int ipage = 0;
         ipage = ram.listPages.FindIndex(p => p.getVide() == true);
         int entree = tablePages.FindIndex(x => x.getPageCorrespandante() == adressePhysique);
         tablePages[entree].setDisponible(true);
         tablePages[entree].setPageCorrespandante(ipage);
         hdd.tableAuxiliere[ipage] = adressePhysique;
         ram.listPages[ipage].setVide(false);
         ram.setNombrePagesLibres(ram.getNombrepagesLibres() - 1);
         lfu.Add(new int[] { ipage, 0 });
     }
 }