设计一个简化的进程管理子系统,可以管理并调度如下简化进程.给出了参考代码
-l PROCESS_LIST, --processlist= X1:Y1,X2:Y2,...
X 是进程的执行指令数;
Y是执行CPU的比例(0..100) ,如果是100,表示不会发出yield操作
instruction_to_execute = self.proc_info[self.curr_proc][PROC_CODE].pop(0)
$./process-simulation.py -l 5:50
Process 0
yld
yld
cpu
cpu
yld
Important behaviors:
System will switch when the current process is FINISHED or ISSUES AN YIELD
Time PID: 0
1 RUN:yld
2 RUN:yld
3 RUN:cpu
4 RUN:cpu
5 RUN:yld
$./process-simulation.py -l 5:50,5:50
Produce a trace of what would happen when you run these processes:
Process 0
yld
yld
cpu
cpu
yld
Process 1
cpu
yld
cpu
cpu
yld
Important behaviors:
System will switch when the current process is FINISHED or ISSUES AN YIELD
Time PID: 0 PID: 1
1 RUN:yld READY
2 READY RUN:cpu
3 READY RUN:yld
4 RUN:yld READY
5 READY RUN:cpu
6 READY RUN:cpu
7 READY RUN:yld
8 RUN:cpu READY
9 RUN:cpu READY
10 RUN:yld READY
11 RUNNING DONE