Me | August 17, 2010
Real life deadlock... I thought about this concept some time ago while studying concurrency between processes. I had a good situation in my mind, one in which there were four processes running like in a highway controlled by a traffic light, like:
As you may already know (by reading maybe my about info), I'm currently living in Lima the capital city of Peru. Normally the traffic in Lima is not bad, except of couse at rush hour. Well a few hours ago I was heading home on the bus, at rush hour of course, when there was a power cut and all the lights went out. The street were dark, the traffic lights weren't working and only the headlights of the cars offered any visibility. It was then that the bus pulled up to an intersection (like in the image above) and my idea was transformed into reality ... deadlock!
A traffic jam had occurred due to the blackout, leaving each of the four lines of cars trying to cross the intersection at the same time. Each line of cars kept pulling forward, until a deadlock was produced. In computer science this situation is presented in the field of concurrency, when two or more processes compete for a unique resource or resources (in this case the shared highway). This situation is overcome with the use of a semaphore (traffic light), which in turns, let pass exclusively two lines of cars at the same time.
In computer science the concept of a semaphore is a little more complex, but with the same goal, which is preventing two or more incompatible processes from using the same resource concurrently, thus achieving mutual exclusion.
To end my story, after ten minutes stuck in the highway, the mutual exclusion task was provided by the traffic police, whom began to order things up. That way real life melt with computer science again in my life.