首页 > 其他分享 >操作系统导论习题解答(4. Processes)

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

时间:2022-10-14 19:15:36浏览次数:78  
标签:Processes clock process request ticks 导论 took 习题 CPU

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.

标签:Processes,clock,process,request,ticks,导论,took,习题,CPU
From: https://www.cnblogs.com/astralcon/p/16792678.html

相关文章