📜  FCFS和C-SCAN磁盘调度算法的区别

📅  最后修改于: 2021-09-27 14:29:35             🧑  作者: Mango

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. C-SCAN 磁盘调度算法:
C-SCAN算法,又称环形电梯算法,是SCAN算法的改进版。在该算法中,头指针从磁盘的一端开始向另一端移动,服务于其间的所有请求。到达另一端后,头部反转方向并转到起点。然后它以与以前相同的方向满足剩余的请求。 C-SCAN 是最好的磁盘调度算法之一。

例子 –
考虑一个有 200 个磁道 (0-199) 的磁盘,磁盘队列的 I/O 请求顺序如下:

98, 183, 40, 122, 10, 124, 65

读/写磁头的当前磁头位置为 53,将向右移动。使用 C-SCAN 算法计算读/写磁头的磁道移动总数。

总的头部运动,

= (65-53)+(98-65)+(122-98)+(124-122)+(183-124)
               +(199-183)+(199-0)+(10-0)+(40-10)
= 395

FCFS 和 C-SCAN 磁盘调度算法的区别:

S.No. FCFS DISK SCHEDULING ALGORITHM C-SCAN DISK SCHEDULING ALGORITHM
1 FCFS is inefficient in seek movements. Whereas C-SCAN is very efficient in seek movements.
2 FCFS cause more average waiting time and response time. But C-SCAN cause less average response time and waiting time.
3 In above example of FCFS, the head starts from 53 and serves the requests in the order of their arrival in disk queue. In the above example of C-SCAN algorithm, the head moves from 53, serves all requests in right direction till it reaches the other end. Then it jumps to the opposite end and serves remaining requests in right direction only.
4 In FCFS algorithm there is decrement in Throughput. Here there is increment in Throughput.
5 FCFS doesn’t cause starvation to any request, but request can experience Convoy effect. In C-SCAN algorithm neither the requests suffers starvation nor Convoy effect.
6 FCFS algorithm is easy to understand and implement. The performance of C-SCAN algorithm is far better than FCFS algorithm.