/// <summary> /// Get a list of system processes. /// </summary> /// <returns> /// An array of all the system process names, indexed by the process ID. /// </returns> public static Primitive GetProcesses() { try { System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcesses(); int count = process.GetLength(0); //Get name and ID, sort on name procs.Clear(); for (int i = 0; i < count; i++) { proc _proc = new proc(process[i].Id, process[i].ProcessName); procs.Add(_proc); } procs.Sort(); //Convert to SB array Primitive processes = ""; foreach (proc _proc in procs) { processes[_proc.ID] = _proc.name; } return processes; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return ""; } }
/// <summary> /// Get a list of system processes. /// </summary> /// <returns> /// An array of all the system process names, indexed by the process ID. /// </returns> public static Primitive GetProcesses() { try { System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcesses(); int count = process.GetLength(0); //Get name and ID, sort on name procs.Clear(); for (int i = 0; i < count; i++) { proc _proc = new proc(process[i].Id, process[i].ProcessName); procs.Add(_proc); } procs.Sort(); //Convert to SB array Primitive processes = ""; foreach (proc _proc in procs) { processes[_proc.ID] = _proc.name; } return(processes); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return(""); } }
private void button2_Click(object sender, EventArgs e) { bmp = new Bitmap(pictureBox1.Width, 10000); Random rnd = new Random(); int rand_count = Convert.ToInt32(txtProsCount.Text); last_x = 0; last_y = 0; up = 0; down = 20; pross = new proc[rand_count]; lblRespond.Visible = true; label3.Visible = true; lstRespond.Visible = true; lblArt.Visible = true; for (int i = 0; i < rand_count; i++) { int rnd_arrival_time = rnd.Next(rand_count + 10); while (!same_arrival_time_control(pross, rnd_arrival_time)) { rnd_arrival_time = rnd.Next(rand_count + 10); } pross[i].arrival_time = rnd_arrival_time; pross[i].proc_name = i.ToString(); pross[i].response_time = -1; } //int max = max_arrival(pross); for (int i = 0; i < rand_count; i++) { int rnd_burst_time = rnd.Next(rand_count + 10, rand_count + 15); pross[i].burst_time = rnd_burst_time; } for (int i = 0; i < pross.Length; i++) { for (int j = i + 1; j < pross.Length; j++) { if (pross[i].arrival_time > pross[j].arrival_time) { proc temp = pross[i]; pross[i] = pross[j]; pross[j] = temp; } } } pross[0].arrival_time = 0; pross[0].burst_time = rnd.Next(rand_count + 20, rand_count + 40); pross[1].burst_time = rnd.Next(rand_count + 20, rand_count + 40); sum_bu = sum_burst(pross); lstArrival.Items.Clear(); lstBurst.Items.Clear(); for (int i = 0; i < pross.Length; i++) { for (int j = 0; j < pross.Length; j++) { if (pross[j].proc_name == i.ToString()) { lstArrival.Items.Add("P" + pross[j].proc_name + "=" + pross[j].arrival_time.ToString()); lstBurst.Items.Add("P" + pross[j].proc_name + "=" + pross[j].burst_time.ToString()); } } } int now = 0; int processed = pross.Length; for (int i = 0; i < processed - 1; i++) { int j = turn_to_be_processed(i); int burst = 0; burst = pross[i + 1].arrival_time - pross[i].arrival_time; pross[j].waiting_time += now - pross[j].arrival_time; if (pross[j].response_time == -1) { pross[j].response_time = now - pross[j].arrival_time; } draw_function(now, burst, pross[j].proc_name, 1); pross[j].burst_time -= burst; if (pross[j].burst_time <= 0) { processed--; } now = now + burst; pross[j].turn_around_time += now - pross[j].arrival_time; pross[j].arrival_time = now; } for (int i = 0; i < pross.Length; i++) { for (int j = i + 1; j < pross.Length; j++) { if ((pross[i].burst_time > pross[j].burst_time)) { proc temp = pross[i]; pross[i] = pross[j]; pross[j] = temp; } } } int k = 0; while (processed != 0) { //pross[k].waiting_time = now - pross[k].arrival_time; int last = 1; if (processed == 1) { last = 0; } if (pross[k].burst_time != 0) { pross[k].waiting_time += now - pross[k].arrival_time; if (pross[k].response_time == -1) { pross[k].response_time = now - pross[k].arrival_time; } draw_function(now, pross[k].burst_time, pross[k].proc_name, last); now += pross[k].burst_time; pross[k].turn_around_time += now - pross[k].arrival_time; ///pross[k].turn_around_time = now - pross[k].arrival_time; processed--; } k++; } //label3.Text = ""; //lbl_arrival.Text = ""; //for (int i = 0; i < pross.Length; i++) //{ // label3.Text += "\n" + pross[i].proc_name + "Waiting time=" + pross[i].waiting_time; // lbl_arrival.Text += "\n" + pross[i].proc_name + "Response time=" + pross[i].response_time; //} double ATT = 0; double AWT = 0; double ART = 0; lstTurnAround.Items.Clear(); lstWaiting.Items.Clear(); lstRespond.Items.Clear(); for (int i = 0; i < pross.Length; i++) { for (int j = 0; j < pross.Length; j++) { if (pross[j].proc_name == i.ToString()) { lstTurnAround.Items.Add("T" + pross[j].proc_name + "=" + pross[j].turn_around_time.ToString()); ATT += pross[j].turn_around_time; lstWaiting.Items.Add("W" + pross[j].proc_name + "=" + pross[j].waiting_time.ToString()); AWT += pross[j].waiting_time; lstRespond.Items.Add("R" + pross[j].proc_name + "=" + pross[j].response_time.ToString()); ART += pross[j].response_time; } } } lblAtt.Text = "ATT : "; lblAwt.Text = "AWT : "; lblArt.Text = "ART : "; lblAtt.Text += (ATT / pross.Length).ToString(); lblAwt.Text += (AWT / pross.Length).ToString(); lblArt.Text += (ART / pross.Length).ToString(); pictureBox1.Image = null; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; bmp = CropImage(bmp, new Rectangle(0, 0, pictureBox1.Width, down + 200)); pictureBox1.Image = bmp; }
private void button1_Click(object sender, EventArgs e) { bmp = new Bitmap(pictureBox1.Width, 10000); Random rnd = new Random(); int rand_count = Convert.ToInt32(txtProsCount.Text); last_x = 0; last_y = 0; up = 0; down = 20; pross = new proc[rand_count]; lblRespond.Visible = false; label3.Visible = false; lblArt.Visible = false; lstRespond.Visible = false; lblRespond.Text = ""; for (int i = 0; i < rand_count; i++) { int rnd_arrival_time = rnd.Next(rand_count + 10); while (!same_arrival_time_control(pross, rnd_arrival_time)) { rnd_arrival_time = rnd.Next(rand_count + 10); } pross[i].arrival_time = rnd_arrival_time; pross[i].proc_name = i.ToString(); } int max = max_arrival(pross); for (int i = 0; i < rand_count; i++) { int rnd_burst_time = rnd.Next(4, 20); pross[i].burst_time = rnd_burst_time; } for (int i = 0; i < pross.Length; i++) { for (int j = i + 1; j < pross.Length; j++) { if (pross[i].arrival_time > pross[j].arrival_time) { proc temp = pross[i]; pross[i] = pross[j]; pross[j] = temp; } } } pross[0].arrival_time = 0; pross[0].burst_time = max + 1; sum_bu = sum_burst(pross); int now = 0; int queue = pross.Length; int k = 0; while (queue != 0) { pross[k].waiting_time = now - pross[k].arrival_time; int last = 1; if (queue == 1) { last = 0; } draw_function(now, pross[k].burst_time, pross[k].proc_name, last); now += pross[k].burst_time; pross[k].turn_around_time = now - pross[k].arrival_time; queue--; k++; } pictureBox1.Image = null; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; //Bitmap bmp_new = new Bitmap(pictureBox1.Width, down + 100); //bmp_new = bmp; //bmp = ResizeImage(bmp,pictureBox1.Width,down+100); bmp = CropImage(bmp, new Rectangle(0, 0, pictureBox1.Width, down + 200)); pictureBox1.Image = bmp; /*for Timearound,Waiting,Respond time*/ int ATT = 0; int AWT = 0; lblturnaround.Text = ""; lblwaiting.Text = ""; lblArrival.Text = ""; lblBurst.Text = ""; lstArrival.Items.Clear(); lstTurnAround.Items.Clear(); lstWaiting.Items.Clear(); lstBurst.Items.Clear(); for (int i = 0; i < pross.Length; i++) { for (int j = 0; j < pross.Length; j++) { if (pross[j].proc_name == i.ToString()) { lstTurnAround.Items.Add("T" + pross[j].proc_name + "=" + pross[j].turn_around_time.ToString()); ATT += pross[j].turn_around_time; lstWaiting.Items.Add("W" + pross[j].proc_name + "=" + pross[j].waiting_time.ToString()); AWT += pross[j].waiting_time; lstArrival.Items.Add("P" + pross[j].proc_name + "=" + pross[j].arrival_time.ToString()); lstBurst.Items.Add("P" + pross[j].proc_name + "=" + pross[j].burst_time.ToString()); } } } lblAtt.Text = "ATT :"; lblAwt.Text = "AWT :"; lblAtt.Text += " " + (ATT / pross.Length).ToString(); lblAwt.Text += " " + (AWT / pross.Length).ToString(); }
private void button2_Click(object sender, EventArgs e) //SJF { bmp = new Bitmap(pictureBox1.Width, 5000); Random rnd = new Random(); int rand_count = Convert.ToInt32(txtProsCount.Text); last_x = 0; last_y = 0; up = 0; down = 20; pross = new proc[rand_count]; lblRespond.Visible = true; label3.Visible = true; lstRespond.Visible = true; lblArt.Visible = true; for (int i = 0; i < rand_count; i++) { int rnd_arrival_time = rnd.Next(1, 10); pross[i].arrival_time = rnd_arrival_time; pross[i].proc_name = i.ToString(); pross[i].response_time = -1; } for (int i = 0; i < rand_count; i++) { int rnd_burst_time = rnd.Next(1, 10); pross[i].burst_time = rnd_burst_time; } for (int i = 0; i < pross.Length; i++) { for (int j = i + 1; j < pross.Length; j++) { if (pross[i].arrival_time > pross[j].arrival_time) { proc temp = pross[i]; pross[i] = pross[j]; pross[j] = temp; } } } int max = max_arrival(pross); pross[0].arrival_time = 0; pross[0].burst_time = max; lstArrival.Items.Clear(); lstBurst.Items.Clear(); for (int i = 0; i < pross.Length; i++) { for (int j = 0; j < pross.Length; j++) { if (pross[j].proc_name == i.ToString()) { lstArrival.Items.Add("P" + pross[j].proc_name + "=" + pross[j].arrival_time.ToString()); lstBurst.Items.Add("P" + pross[j].proc_name + "=" + pross[j].burst_time.ToString()); } } } int now = 0; int processed = pross.Length; for (int i = 0; i < processed - 1; i++) { int j = islenecek_burst_don(i); int burst = 0; bool flag_all_full = false; if (pross[i + 1].arrival_time == pross[i].arrival_time) { int temp = i + 1; int count = 0; while (pross[i + 1].arrival_time == pross[temp].arrival_time) { temp++; count++; if (temp >= pross.Length - 1) { temp = pross.Length - 1; flag_all_full = true; break; } } if (flag_all_full == true) { burst = pross[j].burst_time; break; } else { j = islenecek_burst_don(i + count - 1); burst = pross[temp].arrival_time - pross[i + 1].arrival_time; } i = i + temp - 1; } else { burst = pross[i + 1].arrival_time - pross[i].arrival_time; } if (pross[j].burst_time < burst) { burst = pross[j].burst_time; } if (pross[j].arrival_time > now) { pross[j].waiting_time += 0; } else { pross[j].waiting_time += now - pross[j].arrival_time; } if (pross[j].response_time == -1) { if (pross[j].arrival_time > now) { pross[j].response_time = 0; } else { pross[j].response_time = now - pross[j].arrival_time; } } draw_function(now, burst, pross[j].proc_name, 1); pross[j].burst_time -= burst; if (pross[j].burst_time <= 0) { processed--; } now = now + burst; pross[j].turn_around_time += now - pross[j].arrival_time; pross[j].arrival_time = now; if (flag_all_full == true) { break; } } for (int i = 0; i < pross.Length; i++) { for (int j = i + 1; j < pross.Length; j++) { if ((pross[i].burst_time > pross[j].burst_time)) { proc temp = pross[i]; pross[i] = pross[j]; pross[j] = temp; } } } int k = 0; while (processed != 0) { int last = 1; if (processed == 1) { last = 0; } if (pross[k].burst_time != 0) { if (pross[k].arrival_time > now) { pross[k].waiting_time += 0; } else { pross[k].waiting_time += now - pross[k].arrival_time; } if (pross[k].response_time == -1) { if (pross[k].arrival_time > now) { pross[k].response_time = 0; } else { pross[k].response_time = now - pross[k].arrival_time; } } draw_function(now, pross[k].burst_time, pross[k].proc_name, last); now += pross[k].burst_time; pross[k].turn_around_time += now - pross[k].arrival_time; processed--; } k++; } int ATT = 0; int AWT = 0; int ART = 0; lstTurnAround.Items.Clear(); lstWaiting.Items.Clear(); lstRespond.Items.Clear(); for (int i = 0; i < pross.Length; i++) { for (int j = 0; j < pross.Length; j++) { if (pross[j].proc_name == i.ToString()) { lstTurnAround.Items.Add("T" + pross[j].proc_name + "=" + pross[j].turn_around_time.ToString()); ATT += pross[j].turn_around_time; lstWaiting.Items.Add("W" + pross[j].proc_name + "=" + pross[j].waiting_time.ToString()); AWT += pross[j].waiting_time; lstRespond.Items.Add("R" + pross[j].proc_name + "=" + pross[j].response_time.ToString()); ART += pross[j].response_time; } } } lblAtt.Text = "ATT : "; lblAwt.Text = "AWT : "; lblArt.Text = "ART : "; lblAtt.Text += (ATT / pross.Length).ToString(); lblAwt.Text += (AWT / pross.Length).ToString(); lblArt.Text += (ART / pross.Length).ToString(); pictureBox1.Image = null; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; if (down > 5000) { down = 4800; } bmp = CropImage(bmp, new Rectangle(0, 0, pictureBox1.Width, down + 100)); pictureBox1.Image = bmp; }
+ outp(proc(inp()));
checkCKR(proc(slotId));
BuildStoredProcedure(proc, storedProceduresRegion, procedureDataContextType);
+outp(proc(inp()));