protected void add_process() { process p = new process(spent_time, rnd.Next(1, 15), rnd.Next(0, 139)); queue.Add(p); recently_added_process.Add(p); number_of_created_processes++; }
//constructor private algorithm() { queue = new List <process>(); recently_added_process = new List <process>(); spent_time = 0; number_of_created_processes = 0; running_process = null; }
private void print_process_state(process p) { string message = running_algorithm.spent_time.ToString() + "\t\t"; message += p.name + "\t"; message += p.status + "\t\t"; message += "remaining time: " + p.burst_time + "\t\t"; message += p.priority; log(message); }
private process find_shortest_process(List <process> q) { process output = q.First(); foreach (process p in q) { if (p.burst_time < output.burst_time) { output = p; } } return(output); }
private process find_highest_priority(List <process> q) { process output = q.First(); foreach (process p in q) { if (p.priority < output.priority) { output = p; } } return(output); }
private void general_timer_Tick(object sender, EventArgs e) { print_processes_state(running_algorithm.recently_added_process); running_algorithm.run(); process p = running_algorithm.get_current_process(); if (p == null) { stop_timer(); } else { print_process_state(p); progress_bar.Value = running_algorithm.get_progress(); } }