Esempio n. 1
0
        public void Salvar(Label l)
        {
            Processos p = (Processos)F.retirar();

            if (p != null)
            {
                l.Text = p.ToString();
            }
        }
Esempio n. 2
0
        private void Button5_Click(object sender, EventArgs e)
        {
            if (f2 != null)
            {
                for (int l = 0; l < i.B.Length; l++)
                {
                    i.B[l] = new Fila();
                }

                foreach (Elemento x in f2.b1)
                {
                    Processos p   = (Processos)x.d;
                    int       aux = p.PID;
                    if (aux != p.PID)
                    {
                        switch (p.Prioridade)
                        {
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                        case 10: i.B[p.Prioridade - 1].inserir(novo); break;

                        default:
                            Console.WriteLine("ERRO AO LER O ARQUIVO");
                            break;
                        }
                        if (p.Prioridade == 1)
                        {
                            Processos Pro = (Processos)(novo);
                            if (list1.InvokeRequired)
                            {
                                list1.BeginInvoke((MethodInvoker) delegate {
                                    list1.Items.Add(Pro.ToString());
                                });
                            }
                            Application.DoEvents();
                        }
                        aux = p.PID;
                    }
                }
                for (int o = 0; o < i.B.Length; o++)
                {
                    f2.B2.inserir(i.B[o]);
                }
                i.A1 = f2.B2;
            }
            Thread.Sleep(1000);
        }
Esempio n. 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Elemento  n = (Elemento)list1.Items[list1.SelectedIndex];
            Processos p = (Processos)n.d;

            p.Prioridade = comboBox1.SelectedIndex + 1;
            MessageBox.Show(p.ToString());
            list1.Items.Clear();
            foreach (Elemento x in b1)
            {
                list1.Items.Add(x);
            }
            Application.DoEvents();
            i++;
        }
Esempio n. 4
0
        public static void CarregarProcessos()
        {
            if (File.Exists("1542228_AED_TI_SO_dados.txt"))
            {
                string       linha;
                string[]     info;
                StreamReader entrada = new StreamReader("1542228_AED_TI_SO_dados.txt");
                while (!entrada.EndOfStream)
                {
                    linha = entrada.ReadLine();
                    info  = linha.Split(';');
                    novo  = new Processos(int.Parse(info[0]), info[1], int.Parse(info[2]), int.Parse(info[3]));
                    switch (int.Parse(info[2]))
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10: i.B[int.Parse(info[2]) - 1].inserir(novo); break;

                    default:
                        Console.WriteLine("ERRO AO LER O ARQUIVO");
                        break;
                    }
                    if (int.Parse(info[2]) == 1)
                    {
                        Processos Pro = (Processos)(novo);
                        if (list1.InvokeRequired)
                        {
                            list1.BeginInvoke((MethodInvoker) delegate {
                                list1.Items.Add(Pro.ToString());
                            });
                        }
                        Application.DoEvents();
                    }
                }
                entrada.Close();
                for (int o = 0; o < i.B.Length; o++)
                {
                    i.A1.inserir(i.B[o]);
                }
            }
        }
Esempio n. 5
0
        public void Executar1(Label l1, Label l2, Label l5, ListBox l)
        {
            Monitor.Enter(locker);
            l3 = l1;
            l4 = l2;
            int k = 0;

            for (int i = 0; i < this.B.Length / 2; i++)
            {
                if (l5.InvokeRequired)
                {
                    l5.BeginInvoke((MethodInvoker) delegate { l5.Text = "Lista " + (i + 1); });
                }
                if (A1.ConsultaTopo() != null)
                {
                    F = (Fila)(A1.retirar());
                }
                else
                {
                    F = (Fila)(A1.retirar());
                    A1.inserir(F);
                    F = (Fila)(A1.retirar());
                }
                Processos P;
                while (!F.vazia())
                {
                    P = (Processos)(F.retirar());
                    if (P.Processar() > 0)
                    {
                        if (i != B.Length / 2 - 1)
                        {
                            P.dimPrioridade();
                        }
                        if (i == 0)
                        {
                            A1.ConsultaTopo().prox.d.inserir(P);
                        }
                        else if (i < B.Length / 2 - 1)
                        {
                            A1.ConsultaTopo().d.inserir(P);
                        }
                        else
                        {
                            F.inserir(P);
                        }
                        if (l3.InvokeRequired)
                        {
                            l3.BeginInvoke((MethodInvoker) delegate { l3.Text = "Processo: " + P.Nome + " - PRIORIDADE DIMINUÍDA."; });
                        }
                    }
                    else
                    {
                        if (l4.InvokeRequired)
                        {
                            l4.BeginInvoke((MethodInvoker) delegate { l4.Text = " Processo: " + P.Nome + " - TERMINADO."; });
                        }
                    }
                    if (F != null)
                    {
                        Elemento x = F.ConsultaTopo();
                        if (l.InvokeRequired)
                        {
                            l.BeginInvoke((MethodInvoker) delegate { l.Items.Clear(); });
                        }

                        while (x != null)
                        {
                            Processos pro = (Processos)x.d;
                            if (l.InvokeRequired)
                            {
                                l.BeginInvoke((MethodInvoker) delegate { l.Items.Add(pro.ToString()); });
                            }
                            x = x.prox;
                        }
                    }
                    Application.DoEvents();
                    Thread.Sleep(200);
                }
                k++;
                if (F.vazia())
                {
                    if (l4.InvokeRequired)
                    {
                        l4.BeginInvoke((MethodInvoker) delegate { l4.Text = "FIM - " + k + " filas de processos concluídas."; });
                    }
                }
                Thread.Sleep(2000);
            }
            Monitor.Exit(locker);
        }