{"id":10010,"date":"2025-09-06T19:32:46","date_gmt":"2025-09-06T19:32:46","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=10010"},"modified":"2025-09-06T19:32:46","modified_gmt":"2025-09-06T19:32:46","slug":"disk-scheduling-scan-look-sstf-2","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/disk-scheduling-scan-look-sstf-2\/","title":{"rendered":"Disk Scheduling (SCAN, LOOK, SSTF)"},"content":{"rendered":"<h1>Understanding Disk Scheduling Algorithms: SCAN, LOOK, and SSTF<\/h1>\n<p>Disk scheduling is a critical aspect of operating system design that significantly impacts the performance of disk read and write operations. Ensuring efficient access to data stored on disks can improve overall system performance. In this article, we will explore three popular disk scheduling algorithms: SCAN, LOOK, and SSTF. We will discuss how these algorithms work, their advantages, disadvantages, and use cases.<\/p>\n<h2>What is Disk Scheduling?<\/h2>\n<p>Disk scheduling refers to the method used by an operating system to determine the order in which disk I\/O requests are processed. The primary goal is to reduce seek time and improve the throughput of disk operations. By efficiently scheduling these requests, the system can make better use of its resources, leading to improved user experience and application performance.<\/p>\n<h2>Importance of Disk Scheduling<\/h2>\n<p>Disk drives have mechanical components that take time to move, primarily the read\/write head. When multiple requests are made to access data on the disk, an inefficient order can lead to longer seek times and slower overall system performance. Thus, effective disk scheduling is essential for:<\/p>\n<ul>\n<li><strong>Reducing Latency:<\/strong> Minimizing the time taken to access data.<\/li>\n<li><strong>Increasing Throughput:<\/strong> Maximizing the number of requests processed in a given time.<\/li>\n<li><strong>Fairness:<\/strong> Ensuring all requests get a chance to be serviced without starvation.<\/li>\n<\/ul>\n<h2>Disk Scheduling Algorithms<\/h2>\n<p>Let&#8217;s dive into the three widely used disk scheduling algorithms: SCAN, LOOK, and SSTF.<\/p>\n<h3>1. SCAN Disk Scheduling Algorithm<\/h3>\n<p>The SCAN algorithm, also known as the Elevator algorithm, works similarly to an elevator&#8217;s movement. When servicing requests, the disk arm moves in one direction, fulfilling all requests until it reaches the end of its range, then reverses direction and services requests on the way back.<\/p>\n<h4>How SCAN Works<\/h4>\n<p>The SCAN algorithm executes the following process:<\/p>\n<ol>\n<li>The disk arm begins at an initial position and moves toward the end of the disk in one direction.<\/li>\n<li>All requests in that direction are serviced.<\/li>\n<li>Once the end is reached, the disk arm reverses direction and services all pending requests on the return trip.<\/li>\n<\/ol>\n<h4>Example of SCAN<\/h4>\n<p>Consider a disk queue with the following I\/O requests (in order): 10, 22, 30, 35, 25, and 5. Assume the initial position of the disk arm is 20 and it moves towards the larger numbers.<\/p>\n<pre><code>\nInitial Position: 20\nRequests in Queue: 10, 22, 30, 35, 25, 5\nDirection: Increasing<\/code><\/pre>\n<p>The disk arm will service the requests as follows:<\/p>\n<p><code><br \/>\n1. Move to 22<br \/>\n2. Move to 25<br \/>\n3. Move to 30<br \/>\n4. Move to 35<br \/>\n5. Reverse direction<br \/>\n6. Move to 10<br \/>\n7. Move to 5<br \/>\n<\/code><\/p>\n<h4>Advantages and Disadvantages of SCAN<\/h4>\n<p><strong>Advantages:<\/strong><\/p>\n<ul>\n<li>Reduces overall wait time for requests located close to each other.<\/li>\n<li>Predictable behavior as the direction of movement is consistent.<\/li>\n<\/ul>\n<p><strong>Disadvantages:<\/strong><\/p>\n<ul>\n<li>Starvation can occur for requests located far from the current arm position.<\/li>\n<li>Performance may drop significantly if many requests are concentrated in one area.<\/li>\n<\/ul>\n<h3>2. LOOK Disk Scheduling Algorithm<\/h3>\n<p>The LOOK algorithm is a variation of SCAN that does not traverse the entire disk. Instead, it only goes as far as the last pending request in the current direction before reversing direction.<\/p>\n<h4>How LOOK Works<\/h4>\n<p>LOOK operates as follows:<\/p>\n<ol>\n<li>The disk arm checks for the nearest request in the current direction.<\/li>\n<li>Service requests in that direction until the last request is fulfilled.<\/li>\n<li>Reverse direction and service pending requests until the next traversal is completed.<\/li>\n<\/ol>\n<h4>Example of LOOK<\/h4>\n<p>Using the same queue of requests (10, 22, 30, 35, 25, and 5) with an initial position of 20:<\/p>\n<p><code><br \/>\nInitial Position: 20<br \/>\nRequests: 10, 22, 30, 35, 25, 5<br \/>\nDirection: Increasing<br \/>\nLast Request Service: 35<br \/>\n<\/code><\/p>\n<p>The service order would be:<\/p>\n<p><code><br \/>\n1. Move to 22<br \/>\n2. Move to 25<br \/>\n3. Move to 30<br \/>\n4. Move to 35<br \/>\n5. Reverse direction to move to 10<br \/>\n6. Move to 5<br \/>\n<\/code><\/p>\n<h4>Advantages and Disadvantages of LOOK<\/h4>\n<p><strong>Advantages:<\/strong><\/p>\n<ul>\n<li>Less overhead compared to SCAN, as it does not traverse unneeded areas of the disk.<\/li>\n<li>More efficient in servicing fewer requests.<\/li>\n<\/ul>\n<p><strong>Disadvantages:<\/strong><\/p>\n<ul>\n<li>Like SCAN, it can cause request starvation if demands are far from the arm&#8217;s current position.<\/li>\n<li>Some requests may wait longer if they are not in the direction of the current movement.<\/li>\n<\/ul>\n<h3>3. SSTF (Shortest Seek Time First) Algorithm<\/h3>\n<p>The SSTF algorithm selects the I\/O request that is closest to the current position of the disk arm. Unlike SCAN and LOOK, SSTF operates based on distance rather than direction.<\/p>\n<h4>How SSTF Works<\/h4>\n<p>The SSTF process involves the following steps:<\/p>\n<ol>\n<li>Determine the current position of the disk arm.<\/li>\n<li>Find the nearest request from the current position.<\/li>\n<li>Service that request and repeat until all requests are fulfilled.<\/li>\n<\/ol>\n<h4>Example of SSTF<\/h4>\n<p>Using the same requests (10, 22, 30, 35, 25, and 5) with an initial position of 20:<\/p>\n<p><code><br \/>\nInitial Position: 20<br \/>\nRequests in Queue: 10, 22, 30, 35, 25, 5<br \/>\n<\/code><\/p>\n<p>The sequence of servicing the requests would be:<\/p>\n<p><code><br \/>\n1. Move to 22 (closest to 20)<br \/>\n2. Move to 25<br \/>\n3. Move to 30<br \/>\n4. Move to 35<br \/>\n5. Reverse direction to move to 10<br \/>\n6. Move to 5<br \/>\n<\/code><\/p>\n<h4>Advantages and Disadvantages of SSTF<\/h4>\n<p><strong>Advantages:<\/strong><\/p>\n<ul>\n<li>Minimizes overall seek time on average.<\/li>\n<li>More responsive for nearby requests compared to SCAN and LOOK.<\/li>\n<\/ul>\n<p><strong>Disadvantages:<\/strong><\/p>\n<ul>\n<li>Can cause starvation for requests that are far away from the disk arm&#8217;s current position.<\/li>\n<li>May lead to non-uniform wait times for requests.<\/li>\n<\/ul>\n<h2>Comparative Analysis of Disk Scheduling Algorithms<\/h2>\n<p>Here\u2019s a brief comparison of the three algorithms discussed:<\/p>\n<table>\n<thead>\n<tr>\n<th>Algorithm<\/th>\n<th>Average Wait Time<\/th>\n<th>Starvation<\/th>\n<th>Implementation Complexity<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>SCAN<\/td>\n<td>Moderate<\/td>\n<td>Possible<\/td>\n<td>Easy<\/td>\n<\/tr>\n<tr>\n<td>LOOK<\/td>\n<td>Low<\/td>\n<td>Possible<\/td>\n<td>Easy<\/td>\n<\/tr>\n<tr>\n<td>SSTF<\/td>\n<td>Low<\/td>\n<td>Possible<\/td>\n<td>Moderate<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Conclusion<\/h2>\n<p>Understanding disk scheduling algorithms is essential for developers and systems architects aiming to design efficient disk I\/O operations. The SCAN, LOOK, and SSTF algorithms each have their strengths and weaknesses, suitable for different types of workloads and applications.<\/p>\n<p>While SCAN and LOOK are more systematic in their approach, SSTF strives for the lowest seek time. Developers should consider the specific requirements of their applications when selecting a disk scheduling algorithm, understanding that there is often a trade-off between performance, implementation simplicity, and potential for request starvation.<\/p>\n<p>By carefully choosing the right disk scheduling strategy, you can significantly enhance system performance and ensure a more responsive and efficient user experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understanding Disk Scheduling Algorithms: SCAN, LOOK, and SSTF Disk scheduling is a critical aspect of operating system design that significantly impacts the performance of disk read and write operations. Ensuring efficient access to data stored on disks can improve overall system performance. In this article, we will explore three popular disk scheduling algorithms: SCAN, LOOK,<\/p>\n","protected":false},"author":204,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1147],"tags":[1178,1206,1201,856],"class_list":["post-10010","post","type-post","status-publish","format-standard","category-file-systems-storage","tag-algorithms","tag-disk-scheduling","tag-io","tag-performance"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/10010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/204"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=10010"}],"version-history":[{"count":1,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/10010\/revisions"}],"predecessor-version":[{"id":10011,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/10010\/revisions\/10011"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=10010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=10010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=10010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}