In this project, you will learn the basics of threading a process by implementing a simulation of philosophers at a dinner table. The project explores concepts such as thread creation and mutexes, presenting a unique challenge to manage resource sharing without deadlock.
Philosophy (from Greek, philosophia, meaning "love of wisdom") involves exploring fundamental questions about existence, knowledge, values, and reasoning. This project illustrates a scenario in which philosophers engage in cycles of eating, thinking, and sleeping, demonstrating the need for synchronization and resource management.
- Language: This project is written in C.
- Norm Compliance: The code must adheres to a specified coding norms.
- Error Handling: The functions must not cause unexpected crashes (e.g., segmentation faults).
- Memory Management: All dynamically allocated memory must be freed appropriately—no memory leaks allowed.
- Makefile Requirements: A Makefile with the necessary compilation rules and flags.
- Testing: Created test programs for development;
The simulation involves multiple philosophers sitting at a round table with a bowl of spaghetti. Each philosopher must eat, think, and sleep, managing access to shared resources (forks) carefully to avoid starvation.
- Philosophers cannot communicate or know when another philosopher is about to die.
- Each philosopher needs to eat to survive.
- The simulation ends when a philosopher dies of starvation.