Previous | Next --- Slide 12 of 66
Back to Lecture Thumbnails
superscalar

Not really a real-life example, but as a kid I remember watching a Mr. Bean episode where he and a construction worker were both walking around a large pole while painting it in different colors. Neither was aware that the other was also painting the pole, they'd just be surprised to see that the pole seemingly hadn't been painted.

leave

There is a famous example problem that's used to demonstrate the different challenges in designing concurrent algorithms, including deadlock, livelock and starvation. The problem is called the dining philosophers problem and I find it very intuitive when learning about synchronization. Highly recommend to people who are interested: https://en.wikipedia.org/wiki/Dining_philosophers_problem

alrcdilaliaou

I suppose livelock would be both construction workers going in the same direction and undoing each other's progress, while deadlock would be them going in opposite directions, meeting in the middle, and neither being able to proceed further?

alexder

@leave yes, the dining philosopher's problem is a great example of all of these concurrency challenges. The equivalent to livelock for the dining philosophers would be if all the philosophers pick up their forks at the same time, and then place then down again all at the same time. This would be done repeatedly to create the phenomenon of livelock.

hamood

Might be a dumb question, but given that livelock and deadlock are both bad are there any advantages to running into one of those situations versus the other? For example, livelock might be a better situation to run into than deadlock because at least (in the example given in the slide) the operations will try to reboot and start over again, giving a possibility of breaking out of livelock, while in deadlock it seems like it's going to be stuck there forever.

gsamp

@hamood, I think processes are also stuck in there forever in the case of a livelock. The only difference is that they are not waiting on each other, rather they are doing useless work. In that sense, I believe a livelock is worse than a deadlock because resources are being wasted.

Please log in to leave a comment.