跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2016年8月実施 専門科目II 問題4

Author

祭音Myyura (co-authored with GPT 5.6 SOL)

Description

Consider the problem of scheduling the five processes shown in Table 1. Assume that only one process is allowed to be executed at any instant, and the overhead of process context switches can be ignored. The execution time of each process is also known a priori. Table 2 summarizes the technical terms used in this problem.

Table 1: Arrival time and execution time of the five processes

ProcessABCDE
Arrival time0 ms30 ms40 ms40 ms80 ms
Execution time90 ms10 ms50 ms30 ms20 ms

Table 2: Technical terms used in this problem

TermDefinition
Turnaround timeTime interval from the arrival of the process to the completion of its execution (including the waiting time)
Waiting timeTotal amount of time for which the process is waiting in the ready queue
Response timeTime interval from the arrival of the process to the beginning of its execution

Answer the following questions.

(1) Answer the average turnaround time, average waiting time, and average response time when the processes are scheduled according to the First Come First Serve policy.

(2) Answer the average turnaround time, average waiting time, and average response time when the processes are scheduled according to the non-preemptive Shortest Job First policy.

(3) Answer the average turnaround time, average waiting time, and average response time when the processes are scheduled according to the preemptive Shortest Job First policy.

(4) Answer the average turnaround time, average waiting time, and average response time when the processes are scheduled according to the Round Robin policy where the time slice is 20 ms. Note that time slices are switched in the order of A, B, C, D, E, and that the next time slice starts immediately when the current process does not exhaust its time slice.

(5) Consider the scenario that the five processes shown in Table 1 arrive periodically. The arrival time of the first instance of each process is the arrival time shown in Table 1, and its following instances arrive repeatedly at the constant interval shown in Table 3. If these five processes are scheduled according to the preemptive Rate Monotonic policy, deadline misses occur. Answer when (at what time) the first deadline miss occurs, and to which process it occurs.

Here the Rate Monotonic policy is a scheduling policy that assigns higher priorities to processes with shorter periods; in case the periods are the same, higher priorities are given to processes that arrive earlier. A deadline miss is an event that a periodic process fails to complete its execution before the arrival of its next instance.

Table 3: Inter-arrival time (period) of the five processes

ProcessABCDE
Inter-arrival time (period)200 ms100 ms400 ms100 ms100 ms

题目描述

单处理器调度如下五个进程,忽略上下文切换开销,执行时间均预先已知。

进程ABCDE
到达时刻(ms)030404080
执行时间(ms)9010503020

周转时间为到达至完成(含等待)的时间;等待时间为在就绪队列中的总时间;响应时间为到达至首次开始执行的时间。

(1)采用 FCFS 时,求平均周转、等待、响应时间。

(2)采用非抢占式 SJF 时,求上述三个平均值。

(3)采用抢占式 SJF 时,求上述三个平均值。

(4)采用时间片为 20ms20\rm\,ms 的轮转调度时,求上述三个平均值。时间片按 A、B、C、D、E 的顺序轮转;进程提前结束时下一个时间片立即开始。

(5)现令五个进程周期到达,首次到达时刻同上,周期如下。采用抢占式 Rate Monotonic 调度;周期越短优先级越高,周期相同时首次到达较早者优先级更高。截止期违约指周期进程在下一实例到达前未能完成执行。求第一次截止期违约的时刻和进程。

进程ABCDE
周期(ms)200100400100100

Kai

对每个进程,使用

Tturn=tfinishtarrival,Twait=TturnTexec,Tresp=tfirsttarrival.T_{\rm turn}=t_{\rm finish}-t_{\rm arrival},\qquad T_{\rm wait}=T_{\rm turn}-T_{\rm exec},\qquad T_{\rm resp}=t_{\rm first}-t_{\rm arrival}.

(1)

C,DC,D 同时到达,先按表中顺序将 CC 排在 DD 前。FCFS 的执行顺序为

A[0,90), B[90,100), C[100,150), D[150,180), E[180,200).A[0,90),\ B[90,100),\ C[100,150),\ D[150,180),\ E[180,200).
进程ABCDE平均
周转时间9070110140120106 ms
等待时间0606011010066 ms
响应时间0606011010066 ms

若同时到达时将 DD 排在 CC 前,则顺序为 A,B,D,C,EA,B,D,C,E,平均周转、等待、响应时间分别为 102,62,62ms102,62,62\rm\,ms

(2)

非抢占式 SJF 的顺序为

A[0,90), B[90,100), E[100,120), D[120,150), C[150,200).A[0,90),\ B[90,100),\ E[100,120),\ D[120,150),\ C[150,200).
进程ABCDE平均
周转时间90701601104094 ms
等待时间060110802054 ms
响应时间060110802054 ms

(3)

抢占式 SJF(最短剩余时间优先)的执行区间为

A[0,30), B[30,40), D[40,70), C[70,80), E[80,100), C[100,140), A[140,200).A[0,30),\ B[30,40),\ D[40,70),\ C[70,80),\ E[80,100),\ C[100,140),\ A[140,200).
进程ABCDE平均
周转时间20010100302072 ms
等待时间1100500032 ms
响应时间0030006 ms

(4)

跳过尚未到达或已经结束的进程,可得

A[0,20),A[20,40),B[40,50),C[50,70),D[70,90),E[90,110),A[110,130),C[130,150),D[150,160),A[160,180),C[180,190),A[190,200).\begin{aligned} &A[0,20),A[20,40),B[40,50),C[50,70),D[70,90),E[90,110),\\ &A[110,130),C[130,150),D[150,160),A[160,180),C[180,190),A[190,200). \end{aligned}
进程ABCDE平均
周转时间2002015012030104 ms
等待时间11010100901064 ms
响应时间01010301012 ms

(5)

固定优先级为

B>D>E>A>C.B>D>E>A>C.

200ms200\rm\,ms 为止的执行为

A[0,30),B1[30,40),D1[40,70),A[70,80),E1[80,100),A[100,130),B2[130,140),D2[140,170),A[170,180),E2[180,200).\begin{aligned} &A[0,30),B_1[30,40),D_1[40,70),A[70,80),E_1[80,100),\\ &A[100,130),B_2[130,140),D_2[140,170),A[170,180),E_2[180,200). \end{aligned}

进程 A 的首个实例只执行了 30+10+30+10=80ms30+10+30+10=80\rm\,ms,还剩 10ms10\rm\,ms,而其下一实例在 200ms200\rm\,ms 到达。因此第一次截止期违约发生在

t=200ms,进程 A.\boxed{t=200\rm\,ms,进程\ A}.