博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SRTF:最短剩余时间优先调度算法
阅读量:2532 次
发布时间:2019-05-11

本文共 2163 字,大约阅读时间需要 7 分钟。

SRTF, Which Stands for Shortest Remaining Time First is a scheduling algorithm used in Operating Systems, which can also be called as the preemptive version of the SJF scheduling algorithm. The process which has the least processing time remaining is executed first. As it is a preemptive type of schedule, it is claimed to be better than .

SRTF ,它是最短的剩余时间优先 ,它是操作系统中使用的调度算法,也可以称为SJF调度算法的抢先版本。 首先执行剩余处理时间最少的过程。 由于它是调度的优先类型,因此它比要好。

Let's understand this with the help of an example. Suppose we have the following 3 processes with process ID's P1, P2, and P3 and they arrive into the CPU in the following manner:

让我们借助示例来理解这一点。 假设我们有以下三个进程,进程ID为P1P2P3 ,它们以以下方式到达CPU:

SRJF algorithm

Gant Chart:

甘特图:

SRJF algorithm

Explanation:

说明:

  • At the 0th unit of the CPU, we have only process P1, so it gets executed for the 1-time unit.

    在CPU的 0 单元中,我们只有进程P1 ,因此它以1次单元执行。

  • At the 1st unit of the CPU, the Process P2 also arrives. Now, the P1 needs 7 more units more to be executed, and P2 needs only 2 units. So, P2 is executed by preempting P1.

    在CPU的第一个单元上,过程P2也到达。 现在, P1需要多执行7个单元,而P2仅需要2个单元。 因此,P2被抢占P1执行。

  • P2 gets completed at time unit 3, and unit now no new process has arrived. So, after the completion of P2, again P1 is sent for execution.

    P2在第3单元的时间完成,并且现在没有新的进程到达。 因此,在P2完成之后,再次发送P1以便执行。

  • Now, P1 has been executed for one unit only, and we have an arrival of new process P3 at time unit 4. Now, the P1 needs 6-time units more and P3 needs only 3-time units. So, P3 is executed by preempting P1.

    现在,仅以一个单位执行P1 ,并且新的过程P3以时间单位4到达。现在, P1需要更多的6倍时间单位,而P3仅需要3倍时间单位。 因此,通过抢占P1来执行P3

  • P1 gets completed at time unit 7, and after that, we have the arrival of no other process. So again, P1 is sent for execution, and it gets completed at 13th unit.

    P1在时间单位7处完成,此后,我们没有其他进程到达。 因此,再次发送P1来执行,它以 13 单位完成。

SRJF algorithm
Total Turn Around Time = 13 + 2 + 3                = 18 milliseconds    Average Turn Around Time= Total Turn Around Time / Total No. of Processes                = 18 / 3                = 6 milliseconds    Total Waiting Time = 5 + 0 + 0                = 5 milliseconds    Average Waiting Time = Total Waiting Time / Total No. of Processes                = 5 / 3                = 1.67 milliseconds

翻译自:

转载地址:http://nzxzd.baihongyu.com/

你可能感兴趣的文章
Hibernate视频学习笔记(8)Lazy策略
查看>>
CSS3 结构性伪类选择器(1)
查看>>
IOS 杂笔-14(被人遗忘的owner)
查看>>
自动测试用工具
查看>>
前端基础之BOM和DOM
查看>>
[T-ARA/筷子兄弟][Little Apple]
查看>>
编译Libgdiplus遇到的问题
查看>>
【NOIP 模拟赛】Evensgn 剪树枝 树形dp
查看>>
java学习笔记④MySql数据库--01/02 database table 数据的增删改
查看>>
两台电脑如何实现共享文件
查看>>
组合模式Composite
查看>>
程序员最想得到的十大证件,你最想得到哪个?
查看>>
我的第一篇CBBLOGS博客
查看>>
【MyBean调试笔记】接口的使用和清理
查看>>
07 js自定义函数
查看>>
jQueru中数据交换格式XML和JSON对比
查看>>
form表单序列化后的数据转json对象
查看>>
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>