本文主要是介绍进程调度:一个例子区分响应时间、周转时间和等待时间,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考链接
arrival time:the time when a process enters into the ready state and is ready for its execution.(进程进入就绪态的时刻)
burst time: the total time taken by the process for its execution on the CPU(进程在CPU上执行花费的时间,不包括I/O时间)
响应时间(Response time):Response time is the time spent when the process is in the ready state and gets the CPU for the first time. (自进程就绪至进程第一次获得CPU响应的时间)
Response time = Time at which the process gets the CPU for the first time - Arrival time
周转时间(turnarouad time):Turnaround time is the total amount of time spent by the process from coming in the ready state for the first time to its completion.(进程从第一次进入就绪状态到完成所花费的总时间。)
Turnaround time = Exit time - Arrival time
等待时间(Waiting time):Waiting time is the total time spent by the process in the ready state waiting for CPU.(进程处于就绪状态等待CPU所花费的总时间)
Waiting time = Turnaround time - Burst time
例题:
Suppose round robin scheduler(时间片轮转调度算法) is used and the quantum is 2. Given the below 4 processes:
甘特图:
补充一下就绪队列时刻表:(就绪队列队首的进程即为当前要运行的进程
注:时刻2 :此时p1完成一个时间片,p2到来,先将新进程(p2)插入到就绪队列尾部,再将经过一个时间片后未执行完毕的p1插入到就绪队列尾部。
响应时间(Response time) : (第一次响应 - 到达时间)
P1: 0 - 0 = 0
P2: 2 - 2 = 0
P3: 6 - 3 = 3
P4: 12 - 9 = 3
周转时间(turnarouad time): (结束时刻 - 到达时间)
P1: 14 - 0 = 14
P2: 10 - 2 = 8
P3: 8 - 3 = 5
P4: 13 - 9 = 4
等待时间(Waiting time):(周转时间 - 运行时间)
P1: 14 - 7 = 7
P2: 8 - 4 = 4
P3: 5 - 2 = 3
P4: 4 - 1 = 3
扩展:
带权周转时间 = 周转时间/运行时间
这篇关于进程调度:一个例子区分响应时间、周转时间和等待时间的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!