Пример #1
0
        public bool Equals(IDados other) //método de conferir igualdade de processos por PiD
        {
            Processo aux = (Processo)other;

            if (this.Pid == aux.Pid)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        private void Preencher()
        {
            string[]     texto;
            StreamReader arq = new StreamReader(@"Arquivo.txt");
            //int quant = arq.ReadLine().Count();
            int quant = File.ReadLines(@"Arquivo.txt").Count();

            for (int i = 0; i < quant; i++)
            {
                texto    = arq.ReadLine().Split(';');
                texto[3] = texto[3].Replace(',', '.');
                Processo auxP = new Processo(int.Parse(texto[0]), texto[1], int.Parse(texto[2]), float.Parse(texto[3]), int.Parse(texto[4]));
                prioridades[auxP.Prioridade].Inserir(auxP);
            }
            arq.Close();
        }
Пример #3
0
        public int CompareTo(IDados other) //Comparar os processos e quantidade de vezes a executar
        {
            Processo aux = (Processo)other;

            if (this.Qtd < aux.Qtd)
            {
                return(-1);
            }
            else if (this.Qtd == aux.Qtd)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            ListaProcesso[] processos = new ListaProcesso[33];
            Processo        p;

            for (int i = 0; i < processos.Length; i++)
            {
                processos[i] = new ListaProcesso();
            }
            string arq = "dados_AED_SO_TI.txt";

            if (File.Exists(arq))
            {
                string       linha;
                string[]     aux;
                StreamReader leitura = new StreamReader(arq);
                while (!leitura.EndOfStream)
                {
                    linha = leitura.ReadLine();
                    aux   = linha.Split(';');

                    p = new Processo(int.Parse(aux[0]), aux[1], int.Parse(aux[2]), int.Parse(aux[3]));
                    processos[int.Parse(aux[2])].Inserir(p);
                }

                leitura.Close();
            }
            ProcessarOsDados(processos);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("        ____ ____ ____ ____ ____ ____ ____ ____ ____ ");
            Console.WriteLine("       ||S |||i |||m |||u |||l |||a |||ç |||ã |||o ||");
            Console.WriteLine("       ||__|||__|||__|||__|||__|||__|||__|||__|||__||");
            Console.WriteLine(@"       |/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|");
            Console.WriteLine("");
            Console.WriteLine("        ____ ____ ____ ____ ____ ____ ____ ____ ____ ");
            Console.WriteLine("       ||C |||o |||n |||c |||l |||u |||í |||d |||a ||");
            Console.WriteLine("       ||__|||__|||__|||__|||__|||__|||__|||__|||__||");
            Console.WriteLine(@"       |/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|");
            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("\n\n                          Alunos:");
            Console.WriteLine("                    Andre Luiz Mendes");
            Console.WriteLine("                   Pedro Augusto de Melo");
            Console.WriteLine("                    Gabriel Atene Silva");
            Console.ReadKey();
        }
Пример #5
0
 private void Executar()
 {
     for (int i = 0; i < this.prioridades.Length; i++)
     {
         if (!this.prioridades[i].Vazia())
         {
             Elemento auxE = prioridades[i].Retirar();
             Processo auxP = (Processo)(IDados)auxE;
             if (auxP.Ciclo())
             {
                 finalizados.Inserir(auxP);
             }
             else
             {
                 this.prioridades[auxP.Qtd].Inserir(auxP);
             }
         }
     }
 }
Пример #6
0
        static void InserirProcessos(string local, ListaCircular[] listas)
        {
            Processo     aux;
            string       pid, nome, prioridade, tempo, quant;
            StreamReader reader  = new StreamReader(local);
            string       arquivo = reader.ReadToEnd();

            arquivo = arquivo.Replace("\r", null);
            string[] linhas = arquivo.Split('\n');
            for (int i = 0; i < linhas.Length; i++)
            {
                string[] dados = linhas[i].Split(';');
                pid        = dados[0];
                nome       = dados[1];
                prioridade = dados[2];
                tempo      = dados[3];
                quant      = dados[4];
                aux        = new Processo(int.Parse(pid), nome, int.Parse(prioridade), float.Parse(tempo), int.Parse(quant));
                listas[int.Parse(prioridade)].Inserir(aux);
            }
            reader.Close();
        }
Пример #7
0
 /// <summary>
 /// Construtor do elemento
 /// </summary>
 /// <param name="d">Processo a se inserir</param>
 /// <returns></returns>
 public Elemento(Processo d)
 {
     this.dados = d;
     prox       = null;
 }