Thursday, February 28, 2013

Train token and database locking

I've always had a great fondness for train related pictures. A simple search for the keyword 'train' on this blog will reveal more than 5 posts on the same topic. So today I adding one more in black and white.

The picture captures the tablet being passed to the train driver.


I am made to understand that its a fool proof system. It's used to restrict and make sure that only one train is allowed to traverse through the single track line with bi-directional travel at a given time, thus ensuring no collision could occur on the train line.

While watching this happen it reminded me of locking in databases. Like conflicts on rail lines, in databases we have conflicts in data updates, which need to be avoided. Thus giving rise to different types of lock implementations. Anyway database has some additional levels of complexity and has different types of locks, eg. read lock, write lock, Locking levels, table level, row level, page level etc. Perhaps a bit more complex to solve than the railway problem.

But the interesting thing is when doing algorithm design to solve problems perhaps we can actually find inspiration from past solutions and at times even from nature.

Its an interesting topic read the full detail on wiki http://en.wikipedia.org/wiki/Token_(railway_signalling)

4 comments:

  1. This is really a nice one. I wasn't used to trains in SL and this never got to my attention anyway. Wouldn't mind discussing this in Viyaala Maatram. Good one.

    ReplyDelete
  2. Thanks JK, you can use it, perhaps along with the pic ;)

    ReplyDelete
    Replies
    1. Was gonna ask it. Thanks. Put the note in my drive document already :D

      Delete
  3. Nice analogy to trains Sayy!

    Nice one here about database deadlocks:

    Database locking

    ReplyDelete