18.5. The dining philosophers problem

The discussion above is equally appropriate to resource allocation by operating systems and data object management by a DBMS. The following example demonstrates its applicability to a small concurrent program.

This problem was posed by Dijkstra (1965) and is a classic of concurrent programming:

Five (male) philosophers spend their lives thinking and eating. The philosophers share a common circular table surrounded by five chairs, each belonging to one philosopher. In the centre of the table there is a bowl of spaghetti, and the table is laid with five forks, as shown in Figure 18.3. When a philosopher thinks, he does not interact with other philosophers. From time to time, a philosopher gets hungry. In order ...

Get Operating Systems: Concurrent and Distributed Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.