Exemple #1
0
        private void Run_Click(object sender, EventArgs e)
        {
            if (!readFile)
            {
                return;
            }

            //스케쥴러 실행


            if (comboBox1.Text == "Priority")
            {
                resultList = Priority.Run(pList, resultList);
            }
            else if (comboBox1.Text == "SJF")
            {
                resultList = SJF.Run(pList, resultList);
            }
            else if (comboBox1.Text == "FCFS")
            {
                resultList = FCFS.Run(pList, resultList);
            }
            else if (comboBox1.Text == "Round Robin")
            {
                int i;
                i          = int.Parse(textBox1.Text);
                resultList = RoundRobin.Run(pList, resultList, i);
            }

            else
            {
                MessageBox.Show("스케줄링 방식을 선택하세요.");
            }


            //결과출력
            dataGridView2.Rows.Clear();
            string[] row = { "", "", "", "" };

            double watingTime = 0.0;

            foreach (Result r in resultList)
            {
                row[0]      = r.processID.ToString();
                row[1]      = r.burstTime.ToString();
                row[2]      = r.waitingTime.ToString();
                watingTime += r.waitingTime;

                dataGridView2.Rows.Add(row);
            }

            TRTime.Text = "전체 실행시간: " + (resultList[resultList.Count - 1].startP + resultList[resultList.Count - 1].burstTime).ToString();
            avgRT.Text  = "평균 대기시간: " + (watingTime / count).ToString();
            panel1.Invalidate();
        }
        private void Run_Click(object sender, EventArgs e)
        {
            if (!readFile)
            {
                return;
            }

            if (menuCheck == 1)
            {
                resultList = FCFS.Run(pList, resultList);
            }
            else if (menuCheck == 2)
            {
                resultList = Non_Preemptive_SJF.Run(pList, resultList);
            }
            else if (menuCheck == 3)
            {
                resultList = Preemptive_SJF.Run(pList, resultList);
            }
            else if (menuCheck == 4)
            {
                resultList = Non_Preemptive_Priority.Run(pList, resultList);
            }
            else if (menuCheck == 5)
            {
                resultList = RR.Run(pList, resultList, timeQuantum);
            }

            //결과출력
            dataGridView2.Rows.Clear();



            //값을 받아 왔다 확인해주는 값;
            //값을 집어넣어두는 곳
            if (menuCheck == 3 || menuCheck == 5)
            {
                int[] turnaround = new int[resultList.Count + 1];
                int[] time       = new int[resultList.Count + 1];
                for (int t = 0; t < resultList.Count; t++)
                {
                    turnaround[t] = -1;
                }

                for (int t = resultList.Count - 1; t >= 0; t--)
                {
                    if (turnaround[resultList[t].processID] == -1)
                    {
                        turnaround[resultList[t].processID] = resultList[t].turnaroundTime;
                    }
                    else
                    {
                        continue;
                    }
                }
                for (int t = 0; t < resultList.Count; t++)
                {
                    int tt;
                    for (tt = 0; tt != resultList[t].processID; tt++)
                    {
                        ;
                    }
                    resultList[t].turnaroundTime = turnaround[tt];
                }
            }
            string[] row = { "", "", "", "", "" };

            double waitingTime = 0.0;

            foreach (Result r in resultList)
            {
                row[0]       = r.processID.ToString();
                row[1]       = r.burstTime.ToString();
                row[2]       = r.waitingTime.ToString();
                waitingTime += r.waitingTime;
                row[3]       = r.responseTime.ToString();
                row[4]       = r.turnaroundTime.ToString();
                dataGridView2.Rows.Add(row);
            }
            //////////////
            double avercount = 0.0;

            int[] j = new int[resultList.Count + 1];

            for (int i = 0; i < resultList.Count; i++)
            {
                j[resultList[i].processID] = -1;
            }
            for (int l = 0; l <= resultList.Count; l++)
            {
                if (j[l] == -1)
                {
                    ++avercount;
                }
            }


            double responseTime = 0.0;

            for (int i = 0; i < resultList.Count; i++)
            {
                responseTime += resultList[i].responseTime;
            }
            /////////////////
            TRTime.Text  = "전체 실행시간: " + (resultList[resultList.Count - 1].startP + resultList[resultList.Count - 1].burstTime).ToString();
            avgRT.Text   = "평균 대기시간: " + (waitingTime / avercount).ToString();//원래 resultList.Count
            resTime.Text = "평균 응답시간: " + (responseTime / avercount).ToString();
            panel1.Invalidate();
        }