Homework (Simulation)
This program, process-run.py, allows you to see how process states change as programs run and either use the CPU (e.g., perform an add instruction) or do I/O (e.g., send a request to a disk and wait for it to complete). See the README for details.
Target

Introduction
type python process-run.py -h in the command, you should see:



Question & Answer
1


The CPU utilization is 100%.

2


It takes 10 clock ticks to complete both processes.

First, process 0 was run, it took 4 clock ticks. Then process 1 issued an I/0 request, the CPU received and blocked process 1, it took 1 clock tick. Next the I/O took 4 clock ticks, and finally the CPU unblocked the process 1, process 1 was done, it took 1 clock tick.
3



Process 0 issued an I/O request, the CPU blocked it and started I/O operations, it took 1 clock tick. When I/Os were running, process 1 issued the CPU request, after 4 clock ticks, I/Os and CPU finished. It takes a total of 6 clock ticks.
4


When process 0 is doing I/0, the system will not switch to process 1, instead waiting until the process 0 is completely finished.
5


It is the same as question 3.
6


The system resources are not being effectively utilized.
7


The difference between the two is whether the CPU accepts the next I/O request or runs the process instruction after the I/O operation is executed. Since the default mode SWITCH_ON_IO is adopted, the CPU executes instructions and I/O operations are performed simultaneously, so IO_RUN_IMMEDIATE is 1 clock tick faster.
本文介绍了一个名为process-run.py的Python程序,该程序能够模拟进程运行时的状态变化,包括使用CPU执行指令和进行I/O操作。通过不同的场景设置,可以观察到进程在等待I/O完成或被调度执行时的行为差异。
&spm=1001.2101.3001.5002&articleId=133079187&d=1&t=3&u=a1b0c9831fcf4078826c1ba6670ef5c3)
3945

被折叠的 条评论
为什么被折叠?



