Beispiel #1
0
        public IDados retirar()
        {
            if (this.vazia())
            {
                return(null);
            }
            Elemento aux = this.prim.prox;

            this.prim.prox = aux.prox;
            if (aux == this.ult)
            {
                this.ult = this.prim;
            }
            else
            {
                aux.prox = null;
            }
            return(aux.d);
        }
Beispiel #2
0
 public Elemento(IDados d)
 {
     this.d    = d;
     this.prox = null;
 }
Beispiel #3
0
 public Fila()
 {
     this.prim = new Elemento(null);
     this.ult  = this.prim;
 }
Beispiel #4
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);
        }