Exemplo n.º 1
0
        private void btnResult_Click(object sender, EventArgs e)
        {
            // Quantum = Int32.Parse(tbQuantum.Text);
            Quantumvalue = tbQuantum.Text;
            Quantum      = Int32.Parse(Quantumvalue);
            int[,] table = new int[index, 3];
            // fill the 2D array tabel from the dataGridView
            for (int r = 0; r < dgvQuantum.Rows.Count - 1; r++)
            {
                for (int c = 0; c < dgvQuantum.Rows[r].Cells.Count; c++)
                {
                    table[r, c] = Convert.ToInt32(dgvQuantum.Rows[r].Cells[c].Value);
                }
            }

            Process[] mat_process = new Process[index];

            List <sh_element> scheduler_history_list = new List <sh_element>();

            //float[,] scheduler_history = new float[index, 3];

            //fill the mat_process from the table matrix
            for (int i = 0; i < index; i++)
            {
                mat_process[i] = new Process(0, 0, 0, 0, 0);
                mat_process[i] = new Process(table[i, 0], table[i, 1], table[i, 2], 0, 0);
            }
            avg_wait = Round_Robin(mat_process, scheduler_history_list, Quantum);
            counter  = scheduler_history_list.Count;
            for (int k = 0; k < counter; k++)
            {
                scheduler3cells[k, 0] = scheduler_history_list[k].process_id;
                scheduler3cells[k, 1] = scheduler_history_list[k].start;
                scheduler3cells[k, 2] = scheduler_history_list[k].end;

                //scheduler3cells[k, j] = scheduler_history[k, j];
            }
            chart frm = new chart();

            frm.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnResult_Click(object sender, EventArgs e)
        {
            if (type == "Priority Nonpreemtive")
            {
                int[,] table = new int[index, 4];
                // fill the 2D array tabel from the dataGridView
                for (int r = 0; r < dgv4cells.Rows.Count - 1; r++)
                {
                    for (int c = 0; c < dgv4cells.Rows[r].Cells.Count; c++)
                    {
                        table[r, c] = Convert.ToInt32(dgv4cells.Rows[r].Cells[c].Value);
                    }
                }

                Process[] mat_process = new Process[index];
                float[,] scheduler_history = new float[index, 3];

                //fill the mat_process from the table matrix
                for (int i = 0; i < index; i++)
                {
                    mat_process[i] = new Process(table[i, 0], table[i, 1], table[i, 2], table[i, 3], 0);
                }
                Priority_non_Preemptive(mat_process, scheduler_history);
                counter = index;
                for (int i = 0; i < index; i++)
                {
                    sum_wait += mat_process[i].get_Waiting_Time();
                }
                avg_wait = sum_wait / index;

                for (int k = 0; k < index; k++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        scheduler3cells[k, j] = scheduler_history[k, j];
                    }
                }

                chart frm = new chart();
                frm.ShowDialog();
            }
            if (type == "Priority Preemtive")
            {
                int[,] table = new int[index, 4];
                // fill the 2D array tabel from the dataGridView
                for (int r = 0; r < dgv4cells.Rows.Count - 1; r++)
                {
                    for (int c = 0; c < dgv4cells.Rows[r].Cells.Count; c++)
                    {
                        table[r, c] = Convert.ToInt32(dgv4cells.Rows[r].Cells[c].Value);
                    }
                }

                Process[]         mat_process            = new Process[index];
                List <sh_element> scheduler_history_list = new List <sh_element>();

                //fill the mat_process from the table matrix
                for (int i = 0; i < index; i++)
                {
                    mat_process[i] = new Process(table[i, 0], table[i, 1], table[i, 2], table[i, 3], 0);
                }
                avg_wait = Priority_Preemptive(mat_process, scheduler_history_list);

                counter = scheduler_history_list.Count;
                for (int k = 0; k < counter; k++)
                {
                    scheduler3cells[k, 0] = scheduler_history_list[k].process_id;
                    scheduler3cells[k, 1] = scheduler_history_list[k].start;
                    scheduler3cells[k, 2] = scheduler_history_list[k].end;

                    //scheduler3cells[k, j] = scheduler_history[k, j];
                }
                chart frm = new chart();
                frm.ShowDialog();
            }
        }