4.3. Fairly Sharing a Resource
Our dining philosophers implementation was successful in that it synchronizes the actions of multiple processes competing for limited resources and prevents them from entering into a deadlocked state. However, there is one potential problem it doesn't make any attempt to solve—starvation. Starvation occurs when a process can't access an available resource, because other processes are beating it to the mark—either they are faster, or on a better network connection, or have some other competitive advantage. The dining philosophers code makes no guarantee that every philosopher will eventually get a turn to eat, or that philosophers will eat with the same frequency. Your fellow philosophers might repeatedly beat you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access