Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            qA.Text = String.Empty;
            qB.Text = String.Empty;
            qC.Text = String.Empty;

            textBox2.Text = clockTime.ToString();
            foreach (var p in fifo.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qA.Text += p.getId().ToString() + "\t   " + p.getPrioritas().ToString() + "\t\t" + p.getBurstTime() + Environment.NewLine;
                    qA.Text += "--------------------------------------------------";
                    qA.AppendText(Environment.NewLine);
                }
                else
                {
                    qA.Text += p.getId().ToString() + "\t   " + " " + "\t\t" + "Selesai" + Environment.NewLine;
                    qA.Text += "--------------------------------------------------";
                    qA.AppendText(Environment.NewLine);
                }
            }

            foreach (var p in rr.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qB.Text += p.getId().ToString() + "\t   " + p.getPrioritas().ToString() + "\t\t" + p.getBurstTime() + Environment.NewLine;
                    qB.Text += "--------------------------------------------------";
                    qB.AppendText(Environment.NewLine);
                }
                else
                {
                    qB.Text += p.getId().ToString() + "\t   " + " " + "\t\t" + "Selesai" + Environment.NewLine;
                    qB.Text += "--------------------------------------------------";
                    qB.AppendText(Environment.NewLine);
                }
            }

            foreach (var p in sjf.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qC.Text += p.getId().ToString() + "\t   " + p.getPrioritas().ToString() + "\t\t" + p.getBurstTime() + Environment.NewLine;
                    qC.Text += "--------------------------------------------------";
                    qC.AppendText(Environment.NewLine);
                }
                else
                {
                    qC.Text += p.getId().ToString() + "\t   " + " " + "\t\t" + "Selesai" + Environment.NewLine;
                    qC.Text += "--------------------------------------------------";
                    qC.AppendText(Environment.NewLine);
                }
            }


            Process        ffDemo  = fifo.tick();
            Process        rrDemo  = rr.tick();
            List <Process> sjfDemo = sjf.tick();

            if (sjfDemo.Count > 0)
            {
                foreach (var p in sjfDemo)
                {
                    p.setWaitingClock(0);
                }
                while (fifo.processes.Count < 10 && sjfDemo.Count > 0)
                {
                    rTBlog.Text += "Promosi dari Qc ke Qa dengan ID : " + sjfDemo[0].getId() + " pada clock ke = " + clockTime;
                    sjfDemo[0].setFirst(!sjfDemo[0].getFirst());
                    fifo.processes.Add(sjfDemo[0]);
                    sjfDemo.RemoveAt(0);
                }
                rTBlog.AppendText(Environment.NewLine);
            }

            if (rrDemo.getId() != 0)
            {
                rTBlog.Text += "Demosi dari Qb ke Qc dengan ID : " + rrDemo.getId() + " pada clock ke = " + clockTime;
                rrDemo.setWaitingClock(0);
                rrDemo.setBurstTime(rrDemo.getBurstTime() + 1);
                sjf.processes.Add(rrDemo);
                rTBlog.AppendText(Environment.NewLine);
            }

            if (sjfDemo.Count > 0)
            {
                foreach (var p in sjfDemo)
                {
                    rTBlog.Text += "Demosi dari Qa ke Qb dengan ID : " + p.getId() + " pada clock ke = " + clockTime;

                    rr.processes.AddRange(sjfDemo);
                }
                rTBlog.AppendText(Environment.NewLine);
            }


            if (ffDemo.getId() != 0)
            {
                rTBlog.Text += "Demosi dari Qa ke Qc dengan ID : " + ffDemo.getId() + " pada clock ke = " + clockTime;
                ffDemo.setBurstTime(ffDemo.getBurstTime() + 1);
                sjf.processes.Add(ffDemo);
                rTBlog.AppendText(Environment.NewLine);
            }
            clockTime++;
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = clockTime.ToString();

            foreach (var p in fifo.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qA.Text += "PROSES ID : " + p.getId().ToString() + " ---------> " + p.getBurstTime() + " clock time tersisa, Clock Saat ini = " + clockTime + Environment.NewLine;
                }
                else
                {
                    qA.Text += "PROSES ID : " + p.getId().ToString() + " selesai  ,Clock Saat ini = " + clockTime + Environment.NewLine;
                }
            }
            qA.AppendText(Environment.NewLine);
            foreach (var p in rr.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qB.Text += "PROSES ID : " + p.getId().ToString() + " ---------> " + p.getBurstTime() + " clock time tersisa,  Clock Saat ini = " + clockTime + Environment.NewLine;
                }
                else
                {
                    qB.Text += "PROSES ID : " + p.getId().ToString() + " selesai , Clock Saat ini = " + clockTime + Environment.NewLine;
                }
            }
            qB.AppendText(Environment.NewLine);

            foreach (var p in sjf.processes)
            {
                if (p.getBurstTime() > 0)
                {
                    qC.Text += "PROSES ID : " + p.getId().ToString() + " ---------> " + p.getBurstTime() + " clock time tersisa,  Clock Saat ini = " + clockTime + Environment.NewLine;
                }
                else
                {
                    qC.Text += "PROSES ID : " + p.getId().ToString() + " selesai ,  Clock Saat ini = " + clockTime + Environment.NewLine;
                }
            }
            qC.AppendText(Environment.NewLine);

            fifo.tick();
            Process        rrDemo  = rr.tick();
            List <Process> sjfDemo = sjf.tick();

            if (sjfDemo.Count > 0)
            {
                foreach (var p in sjfDemo)
                {
                    p.setWaitingClock(0);
                }
                while (fifo.processes.Count < 10 && sjfDemo.Count > 0)
                {
                    rTBlog.Text += "Promosi dari Qc ke Qa dengan ID : " + sjfDemo[0].getId() + " pada clock ke = " + clockTime;
                    fifo.processes.Add(sjfDemo[0]);
                    sjfDemo.RemoveAt(0);
                }
                rTBlog.AppendText(Environment.NewLine);
            }

            if (rrDemo.getId() != 0)
            {
                rTBlog.Text += "Promosi dari Qb ke Qc dengan ID : " + rrDemo.getId() + " pada clock ke = " + clockTime;
                rrDemo.setWaitingClock(0);
                sjf.processes.Add(rrDemo);
                rTBlog.AppendText(Environment.NewLine);
            }

            if (sjfDemo.Count > 0)
            {
                foreach (var p in sjfDemo)
                {
                    rTBlog.Text += "Demosi dari Qa ke Qb dengan ID : " + p.getId() + " pada clock ke = " + clockTime;
                    rr.processes.AddRange(sjfDemo);
                }
                rTBlog.AppendText(Environment.NewLine);
            }



            clockTime++;
        }