private void PrProcess_NonPreemptive() { int watingTime = 0; float avaregeTime; List <int> keys = new List <int>(); List <Job_Queue> watingList = new List <Job_Queue>(); int time = 0; int count = 1; foreach (var item in Map.Keys) { keys.Add(item); } foreach (var item in Map.Values) { watingList.AddRange(item); watingList.Sort(new Priority_Sort()); foreach (var job in watingList) { watingTime += time - watingList[0].arrivalTime; table.Rows.Add(job.name, time += job.burstTime); if (count < keys.Count && time >= keys[count]) { count++; break; } } } avaregeTime = (float)watingTime / JobDataList.Count; av_text.Text = avaregeTime.ToString(); DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void PrProcess_NonPreemptive() { List <int> keys = new List <int>(); List <Job_Queue> watingList = new List <Job_Queue>(); int time = 0; int count = 1; foreach (var item in Map.Keys) { keys.Add(item); } foreach (var item in Map.Values) { watingList.AddRange(item); watingList.Sort(new Priority_Sort()); foreach (var job in watingList) { table.Rows.Add(job.name, time += job.burstTime); if (count < keys.Count && time >= keys[count]) { count++; break; } } } DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void RoundProcess() { int watingTime = 0; float avaregeTime; List <int> keys = new List <int>(); List <Job_Queue> watingList = new List <Job_Queue>(); int time = 0; int i = 0; int count = 1; Boolean flag = false; foreach (var item in Map.Keys) { keys.Add(item); } foreach (var item in Map.Values) { watingList.AddRange(item); while (watingList.Count != 0) { if (flag) { flag = false; i++; } else { i = 0; } for ( ; i < watingList.Count; i++) { var job = watingList[i]; watingTime += time - job.arrivalTime; if (job.burstTime > job.sliceTime) { table.Rows.Add(job.name, time += job.sliceTime); job.burstTime -= job.sliceTime; } else { table.Rows.Add(job.name, time += job.burstTime); watingList.RemoveAt(i); i--; } if ((count < keys.Count && time >= keys[count])) { count++; flag = true; break; } } if (flag) { break; } } } avaregeTime = (float)watingTime / JobDataList.Count; av_text.Text = avaregeTime.ToString(); DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void FCFSProcess() { JobDataList.Sort(new Arrival_Sort()); int time = 0; foreach (var job in JobDataList) { table.Rows.Add(job.name, time += job.burstTime); } DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void FCFSProcess() { int watingTime = 0; float avaregeTime; JobDataList.Sort(new Arrival_Sort()); int time = 0; foreach (var job in JobDataList) { watingTime += time - job.arrivalTime; table.Rows.Add(job.name, time += job.burstTime); } avaregeTime = (float)watingTime / JobDataList.Count; av_text.Text = avaregeTime.ToString(); DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void SJFProcess_Preemptive() { List <int> keys = new List <int>(); List <Job_Queue> watingList = new List <Job_Queue>(); List <printedList> PList = new List <printedList>(); int time = 0; // int count = 1; foreach (var item in Map.Keys) { keys.Add(item); } printedList pl = new printedList(); for (int i = 0; i <= keys[keys.Count - 1]; i++) { if (Map.ContainsKey(i)) { watingList.AddRange(Map[i]); watingList.Sort(new Short_Sort()); } if (i == 0) { pl.name = watingList[i].name; pl.duration = i + 1; } else { if (pl.name == watingList[0].name) { pl.duration += 1; } else { PList.Add(pl); pl.name = watingList[0].name; pl.duration = i + 1; } } watingList[0].burstTime -= 1; if (watingList[0].burstTime == 0) { watingList.RemoveAt(0); } } foreach (var i in PList) { table.Rows.Add(i.name, i.duration); } time = keys[keys.Count - 1] + 1; watingList.Sort(new Short_Sort()); foreach (var job in watingList) { table.Rows.Add(job.name, time += job.burstTime); } DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }
private void PrProcess_Preemptive() { int watingTime = 0; float avaregeTime = 0; List <int> keys = new List <int>(); List <Job_Queue> watingList = new List <Job_Queue>(); List <printedList> PList = new List <printedList>(); int time = 0; // int count = 1; foreach (var item in Map.Keys) { keys.Add(item); } printedList pl = new printedList(); for (int i = 0; i <= keys[keys.Count - 1]; i++) { if (Map.ContainsKey(i)) { watingList.AddRange(Map[i]); watingList.Sort(new Priority_Sort()); } // watingTime += time - watingList[0].arrivalTime; if (i == 0) { pl.name = watingList[i].name; pl.duration = i + 1; } else { if (pl.name == watingList[0].name) { pl.duration += 1; } else { PList.Add(pl); watingTime += pl.duration - watingList[0].arrivalTime; pl.name = watingList[0].name; pl.duration = i + 1; } } watingList[0].burstTime -= 1; if (watingList[0].burstTime == 0) { watingList.RemoveAt(0); } } foreach (var i in PList) { table.Rows.Add(i.name, i.duration); } time = keys[keys.Count - 1] + 1; watingList.Sort(new Priority_Sort()); foreach (var job in watingList) { watingTime += time - job.arrivalTime; table.Rows.Add(job.name, time += job.burstTime); } avaregeTime = (float)watingTime / JobDataList.Count; av_text.Text = avaregeTime.ToString(); DGV_QUEUES.DataSource = table; DGV_QUEUES.Update(); DGV_QUEUES.Refresh(); }