📜  SCAN 和 CSCAN 磁盘调度算法的区别

📅  最后修改于: 2021-09-15 01:15:57             🧑  作者: Mango

先决条件 – 磁盘调度算法

1. SCAN 磁盘调度算法:
SCAN 磁盘调度算法也称为电梯算法。在这种情况下,磁头或指针可以在两个方向上移动,即磁盘臂开始从磁盘的一端移动到另一端,为所有请求提供服务,直到它到达磁盘的另一端。到达另一端后,头部运动方向被反转并进一步继续为请求提供服务。

这样做的问题是它需要比 C-SCAN 调度算法更长的等待时间来请求位置。

例子 :
假设头部从 53 开始并开始向左端移动。

总的头部运动,

= (53-37)+(37-14)+(14-0)+(65-0)+(67-65)
             +(98-67)+(122-98)+(124-122)+(183-124)
= 236 

2. C-SCAN 磁盘调度算法:
在 C-SCAN 磁盘调度算法中,与 SCAN 算法的唯一区别在于,它旨在提供更多的等待时间均匀性。在这种情况下,头或指针在单个方向上工作,即,它一直扫描到一个方向的请求,一旦到达终点,它就会跳回到另一端并在同一方向上为请求提供服务,这与 SCAN 不同在反向和正向。

例子:
假设头部从 53 开始并开始向右端移动。

总的头部运动,

= (65-53)+(67-65)+(98-67)+(122-98)+(124-122)
            +(183-124)+(199-183)+(199-0)+(14-0)+(37-14)
= 382 

来看看SCAN和C-SCAN磁盘调度算法的区别——

S. No. SCAN Scheduling Algorithm C-SCAN Scheduling Algorithm
1. It is also known as Elevator Algorithm. It is also known as Circular Elevator Algorithm.
2. It services all the requests in both the direction. It services the requests in one direction only.
3. In above example of SCAN algorithm, head starts moving from 53 towards left servicing all the requests in that direction and further, reaching at left end, it changes the head direction to right and further servicing all the requests from 0 to 199. In above example of C-SCAN algorithm, head starts from 53 toward right servicing all the requests in that direction and after reaching at right end it does not reverses its direction rather, head jumps to the opposite end of the disk servicing the requests on its right.
4. SCAN Algorithm provides a longer waiting time to request the locations. C-SCAN Algorithm provides uniform waiting time in requesting the locations over Elevator Algorithm.
5. It has higher throughput and provides low variance response time. This algorithm provides better response time.