Sunday, July 15, 2012

‘Cracking the System Software Interview’ by Sandhya Mannarswamy and SG Ganesh

Live lock
"Here is a practical example to illustrate live lock. Consider two cars which have reached the two opposite ends of a very narrow bridge. Only one car can pass the bridge at a time. Each car starts first to enter the bridge, sees that the other car is attempting to do the same, and reverses back. This keeps happening and none of the cars makes progress. Though there is continuous change in the state of the cars namely 'starting the engine, checking the position of the other car, and reversing back,' there is no progress made by either of the cars. Hence this situation is called a live lock.'
"Consider two threads T1 and T2. Thread T1 makes a change and thread T2 undoes the change. When this change and undoing the change are done continuously by T1 and T2, it will appear as though lots of work is getting done, but no progress is made. So, this is a 'live lock.'"
(p. 157, 'Cracking the System Software Interview' by Sandhya Mannarswamy and SG Ganesh - TMH)

No comments:

Post a Comment