操作系统导论习题解答(4. Processes)

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值