MaximeJC/42-CommonCore_03.2025_Philo
42 Common Core Rank 03 - "Philo" is a simulation of the famous dining philosophers problem
⚠️ Disclaimer
[ 🇬🇧 ] Please do not copy-paste this code. In this way, you won't learn a lot. Instead, you can use it to understand how to do some tricky part, but try to redo it by your own.
Just to let you know, some files may be incorrect. Some bugs may have passed through, or subject may have changed since I did this project.
[ 🇫🇷 ] S'il vous plait, ne copier-coller pas ce code. De cette manière, vous n'apprendrez pas grand chose. A la place, vous pouvez l'utiliser pour comprendre certaines parties plus complexes du sujet, mais essayez de le refaire par vos propres moyens.
Pour information, certains exercices pourraient être incorrects. Quelques bugs pourraient avoir réussi à passer au travers les mailles du filet, ou le sujet a peut-être changé depuis que j'ai complété le projet.
42-CommonCore_04.2025_Pipex
The goal of this 42 common core project is to solve the "dining philosophers problem", originally formulated in 1965 by Edsger Dijkstra.
There are X philosophers around a table. Each philosopher has one fork on his left. To eat, a philosopher must have two forks, his own, and his right neighbour's one. They each take some time to eat, then some time to sleep, then think while waiting for their two forks to be available to be able to eat again. But if they stay more than a defined time without eating, they die and the simulation stops.
This problem is a good way to discover threads, and importance of mutex to avoid deadlocks and data races.
Usage
./philo nb_of_philos time_to_die time_to_eat time_to_sleep [nb_of_times_each_philo_must_eat]Note that all values must be positive integers and times are in ms.
Common Core Rank 03 - Completed in April 2025
Code by me