(geek stuff) starving in an elevator

I've always read that an "elevator scheduler has obvious starvation issues", but somehow it was never obvious to me.  I know how an elevator works, and the only time an elevator keeps you waiting is if it's stuck on some floor because someone held the door open or too many people were getting on/off.

I just naturally assumed that the analogy breaks down there; after all, if the disk head stops on a sector, it's a hardware fault so this cannot happen.  Hence the puzzlement about the "obvious" starvation.

Well, duh!  The analogy actually breaks down *much* earlier.  Your average elevator has at most 20 stops.  The largest ones maybe a hundred.  So as long as you keep moving and take short (occasionally longer) stops, you're bound to reach any floor soon enough, relatively speaking.

A 500GB disk effectively has a billion "floors", (a sector is 512 bytes, for now anyway).  If someone decides to do a streaming IO before the head gets to your sector, you're effectively starved until that whole stream is done.  And if that's a multi-gigabyte movie or whatever, you'll be waiting a loooong time!

Oh well, at least now I understood the "long distance bus with an enormous number of request stops" scheduler :)

No comments: