Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
LOOK Algorithm 
3.
CLOOK Algorithm
4.
LOOK vs CLOOK 
5.
Frequently Asked Questions
5.1.
Which scheduling has the best performance considering all the algorithms like FCFS, SSTF, SCAN, CSCAN, LOOK, and C-LOOK?
5.2.
In which algorithm, does the disc arm in the algorithm goes as far as the final request in each direction, then instantly reverse direction without reaching the end of the disk?
5.3.
Suppose the requests to be addressed are 176, 79, 34, 60, 92, 11, 41, and 114. The Head pointer starts at 50, and it is also given that the disk arm should move “towards the larger value”. Calculate the seek time.
6.
Conclusion
Last Updated: Mar 27, 2024

LOOK and CLOOK Algorithm

Author Jainish Patel
0 upvote
Operating Systems

Introduction

Today we will be learning about the LOOK disc scheduling algorithm and the CLOOK disc scheduling algorithm. Operating systems do disk scheduling to schedule Input/Output requests arriving for the disk. Disk scheduling is also known as Input/Output scheduling. 

To perform Disc Scheduling, we have 6 Disc Scheduling Algorithms as follows:

Disk Scheduling Algorithms

 

In this article, we will also solve some examples of scheduling based on LOOK and CLOOK algorithms.

LOOK Algorithm 

It is identical to the SCAN disc scheduling algorithm, except that instead of traveling to the end of the track, the disc arm only goes to the last request to be handled in front of the head and then reverses course from there. As a result, the extra time caused by unneeded overhead to the disk end is avoided.

Algorithm

  1. Arrange all the I/O requests in ascending order.
  2. It is provided the initial direction in which the head will move, and it will serve in that direction.
  3. The head responds to each request individually in the direction it is moving.
  4. The head keeps moving in the same direction until all of the requests in that direction have been serviced.
  5. If the last request is reached the direction of the head will be reversed. While reversing the direction, all the pending requests will be serviced. 

 

Consider an example,

Suppose the requests to be addressed are 82, 140, 170, 190, 70, 35, and 20. The Head pointer starts at 50, and it is also given that the disk arm should move “towards the larger value”. Calculate the seek time.

Note: Seek time is the time for the disc arm to move the heads to the cylinder containing the desired sector.

LOOK

The seek time can be calculated as,

Seek time can be calculated by counting the head movements. 

LOOK

OR

By subtracting the last service requests(direction of head pointer) and the head pointer in addition to the last service requests(direction of head pointer)  and last service requests(direction opposite to the head pointer).

The seek time can be calculated as,

LOOK

Advantages

  • The performance of the LOOK algorithm is better compared to the SCAN algorithm since it reduces the overhead. 
  • It can be used in case of less load.
  • It does not result in starvation.
  • It will provide low variance in response time and waiting time.

 

Disadvantages

  • Look algorithm is not recommended to use in terms of heavy load.
  • It causes a long waiting time for the cylinders just visited by the head.

CLOOK Algorithm

CLOOK is comparable to the CSCAN disc scheduling algorithm in the same way that LOOK is comparable to the SCAN algorithm. Despite traveling to the end, the disc arm in CLOOK only goes to the last request to be serviced first in front of the head and then to the opposite end's last request. As a result, it avoids the additional time caused by unneeded traversal to the disk's end.

Algorithm

  1. Arrange all the I/O requests in ascending order.
  2. The initial direction in which the head is moving is given and it serves in the same direction.
  3. The head services all the requests one by one in the direction it is moving.
  4. The head continues to move in the same direction until all the requests in this direction have been serviced.
  5. While reversing the direction, pending requests will not be served which are left to the Head pointer in the case of where the direction is given towards a large number of values. Instead, the disc arm will move directly toward the first request and then reverses its direction to serve the pending requests by moving forth. 
  6. When the direction is given towards the less number of values the procedure would be the same regardless of the direction will change. 

 

Consider an example,

Suppose the requests to be addressed are 82, 140, 170, 190, 70, 35, and 20. Head pointer starts at 50, and it is also given that the disk arm should move “towards the larger value”. Calculate the seek time.

 

C-LOOK

The seek time can be calculated as,

Seek time can be calculated by counting the head movements. 

C-LOOK

OR

By subtracting the last service requests(direction of head pointer) and the head pointer in addition to the first service requests(direction of head pointer)  and last service requests(direction opposite to the head pointer) in addition to the last service requests(direction opposite of head pointer).

The seek time can be calculated as,

C-LOOK

Advantages

  • It provides a more uniform waiting time compared to LOOK and C-SCAN.
  • It is more efficient compared to C-SCAN.

 

Disadvantages

LOOK vs CLOOK 

LOOK vs CLOOK

Also see, Difference between C-LOOK and LOOK Algorithms, Multiprogramming vs Multitasking

Frequently Asked Questions

Which scheduling has the best performance considering all the algorithms like FCFS, SSTF, SCAN, CSCAN, LOOK, and C-LOOK?

CLOOK performance is best in comparison to all the scheduling algorithms. Because of uniform waiting time and response time.


In which algorithm, does the disc arm in the algorithm goes as far as the final request in each direction, then instantly reverse direction without reaching the end of the disk?

Suppose the requests to be addressed are 176, 79, 34, 60, 92, 11, 41, and 114. The Head pointer starts at 50, and it is also given that the disk arm should move “towards the larger value”. Calculate the seek time.

Conclusion

This article discusses how page fault occurs and How Page Fault Handling works in will work in the Operating System

Recommended Reading:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Live masterclass