先决条件–磁盘调度算法
1. FCFS磁盘调度算法:
先到先服务,顾名思义,该算法按照它们到达磁盘队列的顺序来招待任务。它是最简单易懂的磁盘调度算法。在这种情况下,头部或指针沿任务到达的方向移动并移动,直到满足所有请求为止。 FCFS提供了更多的平均等待时间和响应时间。但是,FCFS算法具有处理即将到来的请求的更公平的策略。
例子:
考虑具有200个磁道(0-199)的磁盘和具有I / O请求的磁盘队列,其顺序如下:
98, 183, 40, 122, 10, 124, 65
Read \ Write磁头的当前磁头位置为53。使用FCFS算法计算Read / Write磁头的磁道移动总数。
头部总动作
= (98-53)+(183-98)+(183-40)+(122-40)+(122-10)+(124-10)+(124-65)
= 640
2. SSTF磁盘调度算法:
SSTF代表最短查找时间优先,顾名思义,它服务于最接近头或指针当前位置的请求。在该算法中,头部指针的方向非常重要。如果不知何故,我们在请求之间遇到了障碍,那么负责人将在请求的持续方向上为其提供服务。与FCFS相比,SSTF算法在寻道时间上非常有效。
例子:
考虑具有200个磁道(0-199)的磁盘和具有I / O请求的磁盘队列,其顺序如下:
98, 183, 40, 122, 10, 124, 65
Read \ Write磁头的当前磁头位置为53,它将向右移动。使用SSTF算法计算读/写磁头的磁道移动总数。
头部总动作
= (65-53)+(65-40)+(40-10)+(98-10)+(122-98)+(124-122)+(183-124)
= 240
FCFS和SSTF磁盘调度算法之间的区别:
FCFS SCHEDULING ALGORITHM | SSTF SCHEDULING ALGORITHM | |
---|---|---|
1. | FCFS is not efficient in seek movements. | SSTF is very effective/efficient in seek movements. |
2. | It results in increased total seek time. | It reduces the total seek time as compared to FCFS. |
3. | It provides more average waiting time and response time. | This algorithm provides less average response time and waiting time. |
4. | In this algorithm direction of head does not matters much, which we can clearly see in above example. | But here direction of head plays an important role, in order to break tie between requests and above example is a proof of it. |
5. | This algorithm is the easy to understand and implement. | Here, there is an overhead of finding out the closest request. |
6. | FCFS does not cause starvation to any request (but may suffer from Convoy effect.). | Here, the request which are far from head will suffer starvation. |
7. | In FCFS algorithm there is decrement in Throughput. | Here in SSTF there is increment in Throughput. |