Open In App

Difference Between C-SCAN and SSTF Disk Scheduling Algorithm

Last Updated : 22 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In C-SCAN Algorithm it is necessary to take into account the direction, i.e., larger or smaller value. This algorithm serves disk requests by moving towards their conclusion while SSTF is a secondary storage scheduling method that decides how the disk’s head and arm will move to fulfil read and write requests. In this article, you will discover the distinction between the SSTF and C-SCAN disk scheduling algorithms in this post. However, you must first understand the distinctions between the SSTF and C-SCAN disk scheduling algorithms.

C-SCAN Disk Scheduling Algorithm

The C-SCAN algorithm, also known as the Circular Elevator algorithm is the modified version of the SCAN algorithm. In this algorithm, the head pointer starts from one end of the disk and moves towards the other end, serving all requests in between. After reaching the other end, the head reverses its direction and goes to the starting point. It then satisfies the remaining requests, in the same direction as before. Unlike SSTF, it can handle requests only in one direction. 

Example – Consider a disk with 200 tracks (0-199) and the disk queue having I/O requests in the following order as follows:

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

The current head position of the Read/Write head is 53 and will move in the right direction. Calculate the total number of track movements of the Read/Write head using the C-SCAN algorithm. C-SCAN Total head movements,

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

Algorithm of C-SCAN

  • Step 1: Let the Request array be an array that stores the indexes of the requested tracks in ascending order of arrival time. “head” refers to the disk head’s location.
  • Step 2: From 0 to the disk size, the head only provides services in the correct direction.
  • Step 3: Do not service any rails when travelling in a leftward direction.
  • Step 4: Reverse the direction when we get to the beginning (left end).
  • Step 5: It services each track individually while travelling in the correct direction.
  • Step 6: Determine the track’s absolute distance from the head while proceeding in the correct direction.
  • Step 7: Increase the number of searches made overall at this distance.
  • Step 8: The head position is now the currently served track position.
  • Step 9: Continue from step 6 until we get to the disk’s right end.
  • Step 10: Until all of the songs in the request array have not been served, turn around and go back to step 3 if we reach the right end of the disk.

Advantages of C-SCAN

  • It provides a consistent wait time.
  • It provides a quicker reaction time.
  • Serving every request along the way, the head moves from one disk end to the other.
  • The enhanced SCAN scheduling technique is known as the C-SCAN algorithm.

Disadvantages of C-SCAN

  • In the extreme, it might not be fair to service demand for music.
  • Its seek movements are greater than those of the SCAN Algorithm.

SSTF Disk Scheduling Algorithm

SSTF stands for Shortest Seek Time First, as the name suggests it serves the request which is closest to the current position of head or pointer. In this algorithm, direction of  the head pointer matters a lot. If there occurs a tie between requests, then the head will serve the request in its ongoing direction. Unlike C-SCAN, SSTF algorithm is very efficient in total seek time. 

Example – Consider a disk with 200 tracks (0-199) and the disk queue having I/O requests in the following order as follows:

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

Current head position of the Read/Write head is 53 and will move in Right direction. Calculate the total number of track movements of Read/Write head using SSTF algorithm. SSTF Total head movements,

= (65-53)+(65-40)+(40-10)
+(98-10)+(122-98)+(124-122)+(183-124)
= 240

Algorithm of SSTF

  • Step 1: Let an array containing the indexes of the requested tracks be represented by the Request array. “head” refers to the disk head’s location.
  • Step 2: Determine each track’s positive separation from the head in the request array.
  • Step 3: Select a track with a minimal distance from the head from the specified array that hasn’t been accessed or serviced yet.
  • Step 4: Using this distance, increase the total number of seeks.
  • Step 5: The head position is now the currently serviced track position.
  • Step 6: Repeat step 2 up until the request array’s last track is unserviced.

Advanatages of SSTF

  • It gets better and boosts throughput.
  • The total search time of SSTF is less than that of FCFS.
  • Both the average waiting time and response time are lower.

Disadvantages of SSTF

  • Requests that are made distant from the head may result in starvation.
  • Response and waiting times have a large degree of variety in the SSTF disk scheduling technique.
  • Frequent direction changes of the head slow down the algorithm.

Difference between C-SCAN and SSTF Disk Scheduling Algorithm

C-SCAN

SSTF

C-SCAN algorithm services the requests only in one direction

SSTF algorithm can handle the requests in both directions.

This algorithm causes more seek time as compared to SSTF

In SSTF algorithm, there is an overhead of finding closest request.

Performance of C-SCAN is far better than SSTF.

Whereas SSTF lags in performance.

C-SCAN algorithm provides low variance in average waiting time and response time.

Whereas SSTF provides high variance in average waiting time and response time.

C-SCAN algorithm will never cause starvation to any requests.

SSTF algorithm can cause starvation.

Frequently Asked Question on C-SCAN and SSTF – FAQs

Whose performance is best ?

The performance of C-SCAN is better then SSTF.

Can C-SCAN Algorithm helps in preventing Starvation?

Yes, C-SCAN Algorithm helps in preventing algorithm because it gives guarantee that all requests will be serviced.

Whether SSTF is suitable for minimizing disk arm movement?

Yes, SSTF is helpful in minimizing disk arm movement and it also helps in reducing seek time.

What kind of risk does the SSTF disk scheduling algorithm carry?

The problem occurs when both the disk controller and the host operation system both uses it, causing conflict scheduling.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads