Exemplo n.º 1
0
        public void add_process(int taille, int temps, RAM_fix ram)
        {
            List <int> liste = new List <int>();
            processus  proc;

            int j = 0;
            int i = 0;

            proc = new processus("pr" + id, id++, taille, temps);

            Boolean rech = true;

            i = 0;

            while (i < ram.list_rep.Count)
            {
                liste.Add(ram.list_rep[i].Get_taille() * 1000 + i);
                i++;
            }
            liste.Sort();
            i = 0;
            while ((rech) && (i < liste.Count))
            {
                if (liste[i] / 1000 >= proc.Get_taille())
                {
                    rech = false;
                }
                else
                {
                    i++;
                }
            }
            if (rech == false)//si on trouve la partition qui convient
            {
                j = liste[i] % 1000;
                proc.Set_part(j);
                if ((ram.list_rep[j].G_vide()) == false) //si elle est occupee
                {
                    ram.list_rep[j].f_proc.Add(proc);
                    fifo.Add(proc);
                }
                else//le processus  est ajoute a la liste des proc en cours d'execution
                {
                    proc.Set_etat(1);

                    en_cours.Add(proc);

                    ram.occ_part(ram.list_rep[j], proc, proc.Get_taille());
                }
            }
        }
Exemplo n.º 2
0
        public int Rech_best(processus proc)//retourne l'indice de la partition ou doit etre insere proc
        {
            int        indice = 0;
            Boolean    rech   = true;
            List <int> liste  = new List <int>();

            foreach (int j in list_zone_libre)
            {
                liste.Add(j);
            }
            liste.Sort();
            while ((rech) && (indice < liste.Count))
            {
                if ((liste[indice] / 1000 - proc.Get_taille()) > 0)
                {
                    rech   = false;
                    indice = liste[indice] % 1000;
                }
                else
                {
                    indice++;
                }
            }
            if (rech)
            {
                return(-1);
            }
            else
            {
                return(indice);
            }
        }
Exemplo n.º 3
0
        public int Rech_first(processus proc)//retourne l'indice ou doit etre inseré proc
        {
            Boolean rech = true; int indice = 0;

            while ((rech) && (indice < list_zone_libre.Count))
            {
                if ((list_zone_libre[indice] / 1000 - proc.Get_taille()) > 0)
                {
                    rech = false;

                    indice = list_zone_libre[indice] % 1000;
                }
                else
                {
                    indice++;
                }
            }
            if (rech)
            {
                return(-1);
            }
            else
            {
                return(indice);
            }
        }
Exemplo n.º 4
0
        public int Rech_worst(processus proc)
        {
            //int indice = 0;
            List <int> liste = new List <int>();

            foreach (int j in list_zone_libre)
            {
                liste.Add(j);
            }
            liste.Sort();
            liste.Reverse();
            if (liste[0] / 1000 >= proc.Get_taille())
            {
                return(liste[0] % 1000);
            }
            else
            {
                return(-1);
            }
        }