资源描述
精选优质文档-倾情为你奉上using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 优先级进程调度算法 public class progress public string jincheng; public int youxianji; public int ntime; public progress(string jincheng, int youxianji, int ntime) this.jincheng = jincheng; this.youxianji = youxianji; this.ntime = ntime; public class diaodu static public int pertime = 10; public static void Main() diaodu dia = new diaodu(); progress pro; Console.WriteLine(请输入进程的个数:); int num = Convert.ToInt32(Console.ReadLine(); pro = new progressnum; for (int i = 0; i != num; i+) Console.Write(请输入进程名:); string name = Console.ReadLine(); Console.Write(请输入进程优先级:); int pri = Convert.ToInt32(Console.ReadLine(); Console.Write(请输入进程运行时间:); int tim = Convert.ToInt32(Console.ReadLine(); proi = new progress(name, pri, tim); dia.print(pro); public void print(progress pro) while (true) int k = 0; int max = pro0.youxianji; for (int i = 0; i != pro.Length; i+) if (proi.youxianji = max) max = proi.youxianji; k = i; prok.youxianji-; if (prok.ntime != 0) Console.Write(就绪的进程为:); for (int i = 0; i != pro.Length; i+) if (proi.ntime != 0 & i != k) Console.Write(proi.jincheng + t); Console.WriteLine(); if (prok.ntime = pertime) if (prok.ntime = pertime) Console.WriteLine(当前运行的进程:0运行时间为:1,进程到达的时间为:2 运行结束, prok.jincheng, pertime, k + 1); else Console.WriteLine(当前运行的进程:0运行时间为:1,进程到达的时间为:2, prok.jincheng, pertime, k + 1); prok.ntime -= pertime; else if (prok.ntime 0) Console.WriteLine(当前运行的进程:0运行时间为:1,进程到达的时间为:2 运行结束, prok.jincheng, prok.ntime, k + 1); prok.ntime = 0; bool flag = false; for (int j = 0; j != pro.Length; j+) if (proj.ntime != 0) flag = true; break; if (flag = false) break; 专心-专注-专业
展开阅读全文