示例#1
0
            // done
            public static List <Eprocess> RR(List <Eprocess> RR)
            {
                for (int i = 0; i < RR.Count; ++i)
                {
                    RR[i].status = 1;
                }

                if (RR[0].times == 0)
                {
                    RR.RemoveAt(0);
                }
                else
                {
                    RR[0].times--;
                    if (RR.Count > 1)
                    {
                        RR[1].status = 2;
                    }
                    else if (RR.Count == 1)
                    {
                        RR[0].status = 2;
                    }
                }

                if (RR.Count > 1)
                {
                    if (RR[0].times != 0)
                    {
                        Eprocess Last = RR[0];
                        RR.RemoveAt(0);
                        RR.Add(Last);
                    }
                }
                return(RR);
            }
示例#2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (!IsStart)
     {
         Method.AddRanmodProcess();
         Init();
     }
     else
     {
         if (Method.ProcessArray.Count < 10)
         {
             Eprocess p     = new Eprocess();
             var      seed  = Guid.NewGuid().GetHashCode();
             Random   r     = new Random(seed);
             int      Rname = r.Next(1, 10000);
             // 增加相同id的重新分配
             int Rprimary = r.Next(50, 100);
             int Rtimes   = r.Next(1, 50);
             p.status  = 1;
             p.name    = Rname;
             p.primary = Rprimary;
             p.times   = Rtimes;
             RR.Add(new Eprocess(p.name, p.status, p.primary, p.times));
             DP.Add(new Eprocess(p.name, p.status, p.primary, p.times));
             SRT.Add(new Eprocess(p.name, p.status, p.primary, p.times));
             SPN.Add(new Eprocess(p.name, p.status, p.primary, p.times));
         }
     }
 }
示例#3
0
        public int CompareTo(object obj)
        {
            Eprocess p = (Eprocess)obj;

            if (this.times > p.times)
            {
                return(1);
            }
            if (this.times < p.times)
            {
                return(-1);
            }
            return(0);
        }
示例#4
0
            public static void AddRanmodProcess()
            {
                Eprocess pr    = new Eprocess();
                var      seed  = Guid.NewGuid().GetHashCode();
                Random   r     = new Random(seed);
                int      Rname = r.Next(1, 10000);
                // 增加相同id的重新分配
                int Rprimary = r.Next(50, 100);
                int Rtimes   = r.Next(1, 50);

                pr.status     = 1;
                pr.name       = Rname;
                pr.primary    = Rprimary;
                pr.times      = Rtimes;
                pr.percentage = Rtimes;
                ProcessArray.Add(pr);
            }
示例#5
0
 public static void CreateRandomProcess(int nums)
 {
     ClearArray();
     for (int i = 0; i < nums; ++i)
     {
         Eprocess pr    = new Eprocess();
         var      seed  = Guid.NewGuid().GetHashCode();
         Random   r     = new Random(seed);
         int      Rname = r.Next(1, 10000);
         // 增加相同id的重新分配
         int Rprimary = r.Next(50, 100);
         int Rtimes   = r.Next(1, 50);
         pr.status     = 1;
         pr.name       = Rname;
         pr.primary    = Rprimary;
         pr.times      = Rtimes;
         pr.percentage = Rtimes;
         ProcessArray.Add(pr);
     }
 }