我对我应该保存未完成的过程的位置感到困惑和困惑,并将其与最新时间段内到达的过程一起再次操作。每次检查新进程是否可用时,我的队列都会重置。
//pcount is the no. of process
//tq is the time quantum
string[] process = new string[pcount];
string[] bt_container = new string[pcount];
string[] ct = new string[pcount];
string[] tat = new string[pcount];
string[] wt = new string[pcount];
int c = 0;
int at_counter = 0;
int g = 0;
int timer = 0;
int tq = (int)tq_value.Value;
Array.Copy(bt, bt_container, pcount);
for (int i = 0; i < pcount; i++)
{
process[i] = (i + 1).ToString();
}
g = timer = 0;
// at_dummy[0] = "10000";
while (pcount > 0)
{
c = 0;
at_counter = 0;
for (int i = 0; i < int.Parse(pnum.Text); i++)
{
if (timer >= int.Parse(at_dummy[i]))
{
at_counter++;
}
}
int[] bt_temp = new int[at_counter];
for (int i = 0; i < int.Parse(pnum.Text); i++)
{
if (timer >= int.Parse(at_dummy[i]))
{
bt_temp[c] = int.Parse(bt_container[i]);
c++;
}
}
Queue<int> queue = new Queue<int>();
for (int p=0;p<bt_temp.Length;p++)
{
if (bt_temp[p] != 0)
{
queue.Enqueue(bt_temp[p]);
}
}
if ((queue.ElementAt(0) - tq) != 0)
{
if (at_counter > 1)
{
int temp = queue.ElementAt(0);
queue.Dequeue();
queue.Enqueue(temp);
}
}
bt_container[Array.IndexOf(bt_container, (queue.ElementAt(0).ToString()))] = (queue.ElementAt(0) - tq).ToString();
if (bt_container[Array.IndexOf(bt_container, (queue.ElementAt(0).ToString()))].Equals("0"))
{
at_dummy[Array.IndexOf(bt_container, (queue.ElementAt(0).ToString()))] = "10000";
}
timer += tq;
}