Example #1
0
File: Form4.cs Project: LeiWu103/-
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
            l = list4.ToList <PCB>();
            for (int i = 0; i < 10; i++)
            {
                l.Remove(null);
            }
            l.Sort((a, b) => a.total_time.CompareTo(b.total_time));

            //l.Sort(delegate (PCB p1, PCB p2) { return p1.total_time.CompareTo(p2.total_time); });

            if (l.Count != 0)
            {
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i].arrive_time == 0)
                    {
                        q.Enqueue(l[i]);
                    }
                }
            }
            PCB[] l1 = new PCB[10];
            q.CopyTo(l1, 0);
            for (int i = 0; i < q.Count; i++)
            {
                dataGridView1.Rows.Add(l1[i].process_name, l1[i].total_time.ToString(), l1[i].used_time.ToString());
            }
        }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (list0.Length == 0)
     {
         MessageBox.Show("现在没有进程,请添加!");
     }
     else
     {
         for (int i = 0; list0[i] != null; i++)
         {
             if (list0[i].arrive_time == 0)
             {
                 q1.Enqueue(list0[i]);
             }
         }
         PCB[] list1 = new PCB[10];
         q1.CopyTo(list1, 0);
         for (int i = 0; list1[i] != null; i++)
         {
             dataGridView1.Rows.Add(list1[i].process_name, list1[i].arrive_time, list1[i].used_time, list1[i].total_time);
         }
         timer1.Start();
         timer2.Start();
     }
 }
Example #3
0
File: Form3.cs Project: LeiWu103/-
 private void button1_Click(object sender, EventArgs e)
 {
     timer1.Start();
     for (int i = 0; list3[i] != null; i++)
     {
         if (list3[i].arrive_time == 0)
         {
             q.Enqueue(list3[i]);
         }
     }
     PCB[] list1 = new PCB[10];
     q.CopyTo(list1, 0);
     for (int i = 0; list1[i] != null; i++)
     {
         dataGridView1.Rows.Add(list1[i].process_name, list1[i].arrive_time, list1[i].used_time, list1[i].total_time);
     }
 }
Example #4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     time++;
     for (int i = 0; list0[i] != null; i++)
     {
         if (list0[i].arrive_time == time)
         {
             q1.Enqueue(list0[i]);
             timer2.Start();
             timer3.Stop();
             timer4.Stop();
         }
     }
     label2.Text = time.ToString() + "s";
     label2.Refresh();
     dataGridView1.Rows.Clear();
     dataGridView2.Rows.Clear();
     dataGridView3.Rows.Clear();
     PCB[] list1 = new PCB[10];
     q1.CopyTo(list1, 0);
     for (int i = 0; list1[i] != null; i++)
     {
         dataGridView1.Rows.Add(list1[i].process_name, list1[i].arrive_time, list1[i].used_time);
     }
     PCB[] list2 = new PCB[10];
     q2.CopyTo(list2, 0);
     for (int i = 0; list2[i] != null; i++)
     {
         //dataGridView2.Rows.Clear();
         dataGridView2.Rows.Add(list2[i].process_name, list2[i].arrive_time, list2[i].used_time);
     }
     PCB[] list3 = new PCB[10];
     q3.CopyTo(list3, 0);
     for (int i = 0; list3[i] != null; i++)
     {
         //dataGridView3.Rows.Clear();
         dataGridView3.Rows.Add(list3[i].process_name, list3[i].arrive_time, list3[i].used_time);
     }
 }
Example #5
0
File: Form3.cs Project: LeiWu103/-
        private void timer1_Tick(object sender, EventArgs e)
        {
            time++;
            label1.Text = time.ToString();
            if (q.Count == 0)
            {
                timer1.Stop();
                label2.Visible           = true;
                dataGridView2.Visible    = true;
                dataGridView2.DataSource = list3;
                time = 0;
            }
            else
            {
                q.First().used_time++;
                for (int i = 0; list3[i] != null; i++)
                {
                    if (list3[i].arrive_time == time)
                    {
                        q.Enqueue(list3[i]);
                    }
                }
                if (q.First().used_time >= q.First().total_time)
                {
                    q.First().done_time = time;
                    q.First().wait_time = q.First().done_time - q.First().arrive_time;
                    q.Dequeue();
                }
                dataGridView1.Rows.Clear();
                PCB[] list1 = new PCB[10];
                q.CopyTo(list1, 0);

                for (int i = 0; list1[i] != null; i++)
                {
                    dataGridView1.Rows.Add(list1[i].process_name, list1[i].arrive_time, list1[i].used_time, list1[i].total_time);
                }
            }
        }