From the course: Complete Guide to Parallel and Concurrent Programming with C++

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Abandoned lock

Abandoned lock

- Now that we've figured out how to avoid a deadlock between our two philosophers using chopsticks, we can return to our routine of eating and philosophizing. I'm ready for another piece of sushi, so I'll pick up the first chopstick, then the second one, and I think I left the refrigerator open. - Well, that was rude of him. We've entered another form of a deadlock through thread death. If one thread or process acquires a lock and then terminates because of some unexpected reason, it may not automatically release the lock before it disappears. That leaves other tasks like me stuck waiting for a lock that will never be released and getting hungry. - Sorry about that. Let's look at some code.

Contents