Deadlocks, Operating System

At the end of this lecture, and into the next lecture, we will discuss the last major type of logical error that can occurwhen programming with threads. A deadlock occurswhen two things (threads, processes, etc) wait on each other. One example of a deadlock is known as the Dining Philosophers problem. In this abstract problem, philosophers alternate between thinking and eating, and the dining table has as many forks as philosophers. Each philosopher needs two forks to eat with. The problem which can occur is if each philosopher gets one fork, and will not let go of it. Then no philosopher can get two forks, which he or she needs in order to eat. In this situation, we have a deadlock, and the philosophers will starve!