Friday, August 3, 2007

Programming Lessons on Western Railway - Multiple threads and performance

Western Railway in Mumbai has 4 tracks - slow Up, slow Down, fast Up and fast Down. In order to provide a fast service to passengers in various areas, Western railway has some trains which are slow between Borivli and Andheri and fast between Andheri and Churchgate. There are trains which start or terminate at Andheri and are slow between Andheri and Bandra.
Conditions of passengers at intermediate stations can be very difficult; so, Western Railway has special trains which, e.g. start at Goregaon and are slow up to Andheri and fast after that.
A programmer will see an obvious design concern. These threads will need to be synchronized. Will there be a problem? Every day and night, I experienced the problem. The train would halt and we wait. The design problem was even more severe. To switch between slow and fast tracks, the train had to cross a track with traffic in the opposite direction. More the traffic as at peak hours, worse the synchronization delays.
My brain had nothing else to do during the seemingly endless delays except dream of a different design. If the mind was occupied, the claustrophobia of being surrounded by a mass of humanity seemed less.
My ideal solution - in another post.

No comments:

Post a Comment