Skip to content

Simulates the Dining Philosophers problem using threads and semaphores. Philosophers alternate between thinking, eating, and sleeping, while shared forks are carefully synchronized to avoid deadlocks and starvation. Demonstrates concurrency, resource management, and timing control in C.

Notifications You must be signed in to change notification settings

Alicebaghunts/Philosophers-Sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Project Overview

Implement the classical Dining Philosophers Problem, where philosophers alternately think, eat, and sleep around a table with shared forks. This simulates synchronization, resource contention, and deadlock prevention.

Imagine N philosophers sitting around a circular table. Each philosopher has:

A plate of spaghetti A fork to their left and fork to their right. They must:

  • Think for a while
  • Pick up two forks (left and right) to eat
  • Eat for a while
  • Sleep for a while
  • Repeat...
Philosopher Diagram

Objective

  • Practice multithreading (or multiprocessing in bonus stages).
  • Ensure correct synchronization using mutexes, semaphores, or shared memory.
  • Prevent deadlocks, resource starvation, and race conditions.

My Makefile

Screenshot 2025-08-07 at 14 06 09

About

Simulates the Dining Philosophers problem using threads and semaphores. Philosophers alternate between thinking, eating, and sleeping, while shared forks are carefully synchronized to avoid deadlocks and starvation. Demonstrates concurrency, resource management, and timing control in C.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published