Thursday, July 10, 2008

Hard disks and Elevators

Now, that's a weird title for a post. What follows may sound absurd to some people. But having studied computer science, it makes sense to me.

Many of us work in high rise buildings and more often than not, we take elevators to get to our places of work. My office building has 6 elevators, and 2 control switches - each switch, when pressed, sends request to 3 elevators and one of them eventually services the request.
Recalling from the operating systems course in engineering, the disk request scheduling algorithm heavily borrows from the algorithm used by elevators to service requests. Most of us computer literate people should know that the disk request scheduling algorithm tries to minimize the number of seeks and the distance per seek. The elevator behaves somewhat similarly. For any request, among many elevators receiving the request, the one closest to the origin-place of request services it. Also, if an elevator is already moving in the direction of the origin-place of the request, it handles the request instead of an idle elevator at the same level.
Now, if there was only one elevator in question, then its guaranteed that it would handle requests optimally. But with many elevators and more than one control switch to summon the elevators, the usage could become non-optimal, depending on how people use them. Some of the common things that people do that results in non-optimal usage are:
1) Summoning more than one elevator (activating more than one control switch) for one request
2) Summoning a elevator(s) which are farther away from the origin-place of the request
Think of the elevators in your building as disks, all of them having the same data in them. The amount of distance the elevators need to travel before servicing a request as the seek of a disk. Since there is more than one elevator to choose from, we could choose one (and only one, not more than one! Refer point 1 above) which is closest to the place from which the request is being made.
Advantages:
1) Avoids non-optimal usage - saves power! (GO GREEN!)
2) Provides quicker service!
Disadvantages:
1) You could lose 5 seconds in looking at positions of all elevators before making a decision to summon a particular elevator - This could be offset by point 2 in advantages. Also, is 5 seconds too much, considering the slightly more weighed advantages?)
There are many places like these where we can apply knowledge of computer science, in our daily lives. Its surprising that most of us do not.

8 comments:

  1. You idiot... Use the stairs.. saves electricity and makes you more healthier!!! :P

    ReplyDelete
  2. I get it. You are spending more time waiting for the elevator. OS concepts are just incidental :)

    ReplyDelete
  3. @Naren : LOL! Good one :D

    @Gos and Srini :
    Hmmm interesting point...Are these "computer concepts" mere concepts which have been around for a while and have been incorporated into computer science, or did they have their birth in comp sci?

    Btw, nice post srini..

    ReplyDelete
  4. @Murali - Btw, nice post srini.. WTF?!??!!

    Now tell me, how much did he pay you for that!!!!!!

    ReplyDelete
  5. How about a Solid State disk .. hope u dont face these issues ;-) ... good post .. why dont u post it again on puretechie ?

    ReplyDelete
  6. You forgot to mention the friendship forming effects of waiting for the elevator in the advantages section. That would be a story to tell your grandkids about - how I met your grandmother!

    ReplyDelete
  7. Holy Cow!!! U need a break from work bad!!!


    'also. this is an example of common knowledge being applied in computer algorithms and not the other way round :)

    ReplyDelete
  8. Naren, Gos - damn! can't give one serious comment?? :P

    Murali, Sanjiv - Yes, these concepts have been around and have been applied in computer science. But it can also be applied back in dialy lives as well :)

    Arvind - posted to puretechie

    Avinash - Already planning about what tales you would tell your grandkids eh?!

    ReplyDelete

What I want to say is: