Search code examples
algorithmschedulingdisk

SCAN and LOOK disk scheduling


Suppose the disk is idle but has a direction that the read head was heading in before it became idle. (Say the read-head is in sector 5 and previously read sector 1, but there are no requests now.) When a request comes, will the read head continue in the direction it was heading before, or can it choose the other direction? (Say a request comes for sector 4, in the example, would it then have to continue in positive direction or could it start reversing at once?) LOOK would simply return, but should SCAN go all the way to the end?

Also, say I'm heading outwards (from 1 to 100) and I am heading for sector 90 but before I get there another request appears that is between mi current position and sector 90, do I read that and then head for 90, or do I keep going to 90 and then head back?


Solution

  • For your first scenario (you have no pending I/O, disk is at cylinder 5) going outwards and a request to cylinder 4 comes:

    • With SCAN the head of the disk would still need to go to the last cylinder and then go back to cylinder 4
    • With LOOK as there were no more requests it can reverse direction to service request at cylinder 4

    In your second scenario (you are heading outwards to cylinder 90 but before you get there another request appears between your current position and cylinder 90):

    In this case with either SCAN or LOOK you would service all the requests waiting to be serviced which are located under the current head position. Therefore in your example it would service the second request before servicing the one at cylinder 90.