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

📅  最后修改于: 2021-09-14 01:18:31             🧑  作者: Mango

一、FCFS磁盘调度算法

FCFS 代表先到先得,该算法按照任务到达磁盘队列的顺序来处理任务。它是最简单易懂的磁盘调度算法。在这种情况下,头部或指针向任务到达的方向移动,并移动直到所有请求都得到服务。但是,FCFS 算法在处理即将到来的请求方面具有更公平的策略。与所有剩余的磁盘调度算法相比,FCFS 算法在性能上有所滞后。

例子:

考虑一个有 200 个磁道 (0-199) 的磁盘,磁盘队列的 I/O 请求顺序如下: 98, 183, 40, 122, 10, 124, 65. Read\Write 的当前磁头位置head 为 53。使用 FCFS 算法计算 Read/Write head 的磁道移动总数。

Total head movements
= (98-53)+(183-98)+(183-40)
  +(122-40)+(122-10)+(124-10)+(124-65)
= 640

2. C-LOOK 磁盘调度算法

C-LOOK 是 LOOK 算法的修改版本。在这个算法中,头部从一个方向的第一个请求开始,向另一端的最后一个请求移动,为中间的所有请求提供服务。在一端到达最后一个请求后,头部向另一个方向跳转,向剩余的请求移动,然后在与之前相同的方向满足它们。 C-LOOK 算法只服务于一个方向的请求。与 FCFS 不同,它不按到达顺序处理请求。

例子 :

考虑一个有 200 个磁道 (0-199) 的磁盘,磁盘队列的 I/O 请求顺序如下: 98, 183, 40, 122, 10, 124, 65. Read/Write 的当前磁头位置head 是 53 并且会朝正确的方向移动。使用 C-LOOK 算法计算读/写磁头的磁道移动总数。

Total head movements
= (65-53)+(98-65)+(122-98)
  +(124-122)+(183-124)+(183-10)+(40-10)
= 333

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

S.No. FCFS DISK SCHEDULING ALGORITHM C-LOOK DISK SCHEDULING ALGORITHM
1. FCFS algorithm is easy to understand and implement. In C-LOOK there is an overhead of finding end requestssufferthe .
2. In FCFS algorithm there is high variance in response time and waiting time. In C-LOOK there is low variance in response time and waiting time.
3. FCFS doesn’t cause starvation to any request, but request can experience Convoy effect. In C-LOOK algorithm neither the requests suffers starvation nor Convoy effect.
4. FCFS is inefficient in seek movements. But it is very efficient in terms of seek movement in all the disk scheduling algorithms.
5. In the above example of FCFS, the head starts from 53 and serves the requests in the order of their arrival in disk queue. In above example of C-LOOK algorithm, the head moves from 53, serves all requests in the right direction till it reaches the last request in one end. Then it jumps to the remaining requests and serves them in the right direction only.
6. In FCFS algorithm Throughput decreases. In C-LOOK algorithm Throughput increases.

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程。