Using the elevator algorithm for processing disk requests, suppose requests arrive in the order: 8, 36, 34, 12.... (These numbers are cylinder numbers). Suppose the direction is UP meaning that the arm is taking on higher requests. Here we can see that both 36 and 34 are higher requests but 36 comes before 34, So, I'm confused if the algorithm addresses shortest distance between consecutive higher requests, because it was not addressed in the algorithm.
-
$\begingroup$ In my experience with elevators, I wouldn't even dare predicting what any elevator algorithm would do. I think Donald Knuth wrote that he spent some time observing an elevator where he worked, and never managed to figure out the algorithm used. $\endgroup$gnasher729– gnasher7292018年04月21日 19:07:48 +00:00Commented Apr 21, 2018 at 19:07
-
$\begingroup$ @gnasher729 Just be clear, this question is about a disk scheduling algorithm named after elevators, not a model of how an actual elevator behaves. $\endgroup$Discrete lizard– Discrete lizard ♦2018年04月21日 21:11:59 +00:00Commented Apr 21, 2018 at 21:11
1 Answer 1
The idea is that you guarantee that every request will be satisfied eventually by moving in one direction until there are no further requests in the same direction. The arrival order doesn't matter as much as the arrival times - any first request to an otherwise empty queue is scheduled immediately and set the direction. When that request is satisfied, look for additional requests in the same direction, then if none, reverse direction.
-
$\begingroup$ so in the above question, the request for 34 will only be proceeded only when the direction is reversed, right? $\endgroup$mathmaniage– mathmaniage2018年04月22日 02:38:28 +00:00Commented Apr 22, 2018 at 2:38