예제 #1
0
        private void cmdInicio_Click(object sender, EventArgs e)
        {
            txtInfo.Clear();

            Proceador Procesador = new Proceador();
            Random    r          = new Random();
            @base     P1;

            int totalPro  = 0;
            int proEmpty  = 0;
            int numMaxPro = 0;

            for (int i = 0; i < 200; i++)
            {
                if (r.Next(1, 101) <= 30)
                {
                    P1 = new @base(r.Next(4, 13));
                    Procesador.mAgregar(P1);
                    P1.Proceso = numMaxPro;
                    numMaxPro++;
                }

                P1 = Procesador.mActual();

                if (P1 != null)
                {
                    P1.Tiempo--;

                    if (P1.Tiempo == 0)
                    {
                        Procesador.mEliminar(P1);
                        totalPro++;
                    }

                    Procesador.mMoverSiguiente();
                }
                else
                {
                    proEmpty++;
                }
            }

            txtInfo.Text = Procesador.mListar();

            txtMaximo.Text    = numMaxPro.ToString();
            txtAtendidos.Text = totalPro.ToString();
            txtRestantes.Text = proEmpty.ToString();
            txtVacios.Text    = Procesador._proPen.ToString();
            textBox1.Text     = Procesador._cicPen.ToString();
        }
예제 #2
0
        private void cmdInicio_Click(object sender, EventArgs e)
        {
            Proceador Procesador = new Proceador();
            Random    r          = new Random();
            @base     P1;

            int totalPro  = 0;
            int proEmpty  = 0;
            int numMaxPro = 0;
            int numPend   = 0;

            for (int i = 0; i < 200; i++)
            {
                if (r.Next(1, 101) <= 35)
                {
                    P1 = new @base(r.Next(4, 11));
                    Procesador.Enqueue(P1);
                    numMaxPro++;
                    numPend++;
                }

                P1 = Procesador.Peek;

                if (P1 != null)
                {
                    P1.Tiempo--;
                    if (P1.Tiempo == 0)
                    {
                        Procesador.Dequeue();
                        totalPro++;
                        numPend--;
                    }
                }
                else
                {
                    proEmpty++;
                }
            }

            txtMaximo.Text    = numMaxPro.ToString();
            txtAtendidos.Text = totalPro.ToString();
            txtRestantes.Text = proEmpty.ToString();
            txtVacios.Text    = numPend.ToString();
        }