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

📅  最后修改于: 2021-09-13 02:56:10             🧑  作者: Mango

C-LOOK 磁盘调度算法

C-LOOK 是 LOOK 和 C-scan 算法的修改版本。在该算法中,头部从一个方向的第一个请求开始,并在另一端向最后一个请求移动,为中间的所有请求提供服务。在一端到达最后一个请求后,头部向另一个方向跳转,向剩余的请求移动,然后在与之前相同的方向满足它们。与 C-SCAN 不同,头指针将移动到磁盘的结束请求。

例子 :

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

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

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

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

C-SCAN 磁盘调度算法

C-scan算法,又称环形电梯算法,是SCAN算法的改进版。在该算法中,头指针从磁盘的一端开始向另一端移动,服务于其间的所有请求。到达另一端后,头部反转方向并转到起点。然后它在与以前相同的方向上满足剩余的请求。与 C-LOOK 不同的是,无论是否有请求,头指针都会移动到磁盘的末尾。

例子 –

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

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

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

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

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

  C-LOOK C-SCAN
1 C-LOOK algorithm has the best performance in all disk scheduling algorithms. Whereas C-SCAN lags in performance, when compared to C-LOOK
2 C-LOOK algorithm can handle requests more effectively than C-SCAN. Here handling of request is not so good as compared to C-LOOK algorithm.
3 In above example of C-LOOK algorithm, the head moves from 53, serves all requests in right direction till it reaches the last request in one end. Then it jumps to the remaining requests and serve them in right direction only. In 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 opposite end and serve remaining requests in right direction only.
4 C-LOOK provides low variance in response time and waiting time. C-SCAN provides uniform waiting time and response time.
5 In C-LOOK algorithm, there is an overhead of finding the end requests. C-SCAN algorithm causes more seek time as compared to C-LOOK.

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