public static string 优先级调度算法(queue q, queuefinish p) { string msg; process p1; if (q.length > 0) { if (q.now_process == null) { q.now_process = q.del_highest_priority(); } if (q.now_process.period_need_left <= 0) { msg = "完成job" + q.now_process.num.ToString() + "\r\n"; q.now_process.time_out = q.now_process.wait_already + q.now_process._need_period_num + q.now_process._time_in; p.wait[p.length++] = q.now_process; q.now_process = q.del_highest_priority(); return msg; } else if (q.now_process.prior > (p1 = (q.length > 0 ? q.del_highest_priority() : q.now_process)).prior) { q.add(q.now_process); q.now_process = p1; return null; } else { if (q.now_process != p1) q.add(p1); return null; } } else if (q.now_process != null && q.now_process.period_need_left <= 0) { msg = "完成job" + q.now_process.num + "\r\n"; q.now_process.time_out = q.now_process.wait_already + q.now_process._need_period_num + q.now_process._time_in; p.wait[p.length++] = q.now_process; q.now_process = null; return msg; } else return null; }
public static string RR(queue q,queuefinish p) { string msg; process p1; if (q.length > 0) { if (q.now_process == null) { q.now_process = q.del_first(); } if (q.now_process.period_need_left <= 0) { msg = "完成job" + q.now_process.num.ToString() + "\r\n"; q.now_process.time_out = q.now_process.wait_already + q.now_process._need_period_num + q.now_process._time_in; p.wait[p.length++] = q.now_process; q.now_process = q.del_first(); return msg; } else if (Form1.time_interval==0&&Form1 .change_enable==true) { q.add(q.now_process); p1=q.del_first(); q.now_process = p1; Form1.change_enable =false ; return null; } else { return null; } } else if (q.now_process != null && q.now_process.period_need_left <= 0) { msg = "完成job" + q.now_process.num + "\r\n"; q.now_process.time_out = q.now_process.wait_already + q.now_process._need_period_num + q.now_process._time_in; p.wait[p.length++] = q.now_process; q.now_process = null; return msg; } else return null; }