Disk Scheduling algorithm

Source: Internet
Author: User

Disk scheduling algorithm
Disk scheduling in a multi-channel program-designed computer system, each process may constantly present different requests for read/write operations on the disk. Because sometimes these processes send requests faster than disk response, it is necessary for each disk device to establish a waiting queue, the common disk scheduling algorithm has the following four kinds: [1] first come first service algorithm (FCFS), shortest seek time First algorithm (SSTF), scanning algorithm (scan), cyclic scanning algorithm (Cscan)Disk scheduling algorithmThe time to read and write operations on a disk is determined by the search (seek) time, delay time, and transmission time:[1] 1) Find time TS: The time required for the active head disk to move the head to the specified track before reading and writing information. This time, in addition to the time across N tracks, includes the time s for the start of the magnetic arm, i.e. Ts = m * n + S. , M is a constant relative to the speed of the disk drive, approximately 0.2ms, and the start-up time of the magnetic arm is about 2ms. 2) Delay Time Tr: The time required for the head to locate the sector (block number) of a track, set the rotation speed of the disk to R, then: Tr = 1/(2 * r). For hard disks, the typical rotational speed is 5400r/m, which is equivalent to 11.1ms a week, then the TR is 5.55ms, and for a floppy disk, the rotation speed is between 300~600r/m, then the TR is 50~100ms. 3) Transfer time Tt: The time it takes to read from disk or write data to disk, depending on the number of bytes read/write and the speed at which the disk is rotated: Tt = b/(R * N). , R is the number of RPM disks per second, and N is the number of bytes on a track. In the calculation of disk access time, the seek time is related to the disk scheduling algorithm, the following will be introduced to analyze several algorithms, and the delay time and transmission time are related to disk rotation speed, and linear correlation, so on the hardware, speed is a very important parameter of disk performance. The total average access time TA can be expressed as: Ta = Ts + Tr + Tt. Although the formula for the total average access time is given here, the average value is not significant because the access time is closely related to the disk scheduling algorithm in the actual disk I/O operation. The scheduling algorithm directly determines the time to search, thus determining the total access time.Disk scheduling algorithmCommon disk scheduling algorithmsDisk scheduling algorithmFirst come first service algorithm FCFS algorithm based on the process request access to disk sequencing, which is the simplest scheduling algorithm. The advantage of this algorithm is fairness. If only a small number of processes need access, and most of the requests are access to clustered file sectors, it is expected to achieve better performance, but if there are a large number of processes competing to use the disk, then this algorithm in performance is often close to random scheduling. Therefore, some more complicated scheduling algorithms are considered in actual disk scheduling.[1] 1, the idea of the algorithm: according to the order of access requests arrived service. 2, Advantages: simple, fair. 3, disadvantage: The efficiency is not high, the adjacent two requests may cause the most inside to the most outer cylinder seeks the road, causes the head to move repeatedly, increases the service time, to the machinery also unfavorable. 4, Example: Assume disk access sequence: 98,183,37,122,14,124,65,67. Read/write header starting position: 53. The total distance (number of paths) of the head service sequence and the head movement. By the idea of test instructions and first-come-first service algorithm, the head movement trajectory shown is obtained. Thus: The head service sequence is: 98,183,37,122,14,124,65,67 head movement Total distance = (98-53) + (183-98) +|37-183|+ (122-37) +|14-122|+ (124-14) +|65-124|+ (67-65) =640 (track)FCFS Disk scheduling algorithmShortest Search Time First algorithm[1] SSTF algorithm selection scheduling processing track is the current magnetic head with the closest track distance, so that the shortest time to find. Of course, always choosing the minimum search time does not guarantee that the average search time is minimal, but it can provide better performance than the FCFS algorithm. This algorithm produces a "hunger" phenomenon. 1, the algorithm idea: the priority choice is from the current head the recent request service, the main consideration seeks the road first. 2, Advantages: Improve the average disk service time. 3. Disadvantages: Cause some access requests to wait for a long time without service. 4, Example: to the above example of the disk access sequence, the head movement can be the trajectory of such as.Disk scheduling algorithmScan algorithm (also known as elevator algorithm) the scan algorithm selects the closest request to the current head in the direction of movement of the magnetic head as the next service object. Because the head movement law is similar to the elevator operation, it is also called the elevator scheduling algorithm. The scan algorithm is not fair to the recently scanned area, so it is not as good as the FCFS algorithm and the SSTF algorithm in accessing locality.[1] algorithm thought: When the device has no access request, the head does not move; when there is a request for access, the head moves in one direction, moving[2] During the operation of the access request encountered in the service, and then determine whether there are access requests in the direction, if any, continue to scan, otherwise change the direction of movement, and for the access request service, so repeated. As shown: Scanning algorithm (elevator algorithm) of the head movement trajectory 2, advantages: Overcome the shortest seek the first disadvantage, not only consider the distance, but also consider the direction.Disk scheduling algorithmBased on the scanning algorithm, the cyclic scanning algorithm provides a one-way movement of the head to provide service, and moves directly to the starting end without service of any request when returning. Because the scan algorithm prefers to handle access requests that are close to the most or the most out of the tracks, the improved C-scan algorithm is used to avoid this problem. When using the scan algorithm and the C-scan algorithm, the head always strictly follows from one end of the disk surface to the other, obviously, in actual use can also be improved, that is, the head movement only needs to reach the furthest end of a request can return, do not need to reach the disk endpoint. This form of scan algorithm and C-scan algorithm is called look and c-look scheduling. This is because they see if they have a request before moving in a given direction. Note that the default scan algorithm and the C-scan algorithm can be scheduled for look and C-look without special instructions.Disk scheduling algorithmComparison

  
Advantages Disadvantages
FCFS algorithm Fair and simple The average seek distance is large and applies only when the disk I/O is low
SSTF algorithm Performance ratio "first come first service" good There is no guarantee that the average seek time is the shortest, there may be "starvation" phenomenon
Scan algorithm Better seek performance to avoid "hunger" phenomenon Not conducive to access requests from one end of the head
C-scan algorithm Eliminates the unfairness of the two-track request --

Disk Scheduling algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.