https://github.com/pcapurro/42philosophers
A complex simulation of threads set up with the arguments specified by the user.
https://github.com/pcapurro/42philosophers
mutex posix pthread semaphore synchronization thread
Last synced: 11 months ago
JSON representation
A complex simulation of threads set up with the arguments specified by the user.
- Host: GitHub
- URL: https://github.com/pcapurro/42philosophers
- Owner: pcapurro
- Created: 2024-10-09T08:20:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-10T12:00:12.000Z (over 1 year ago)
- Last Synced: 2025-02-07T08:46:26.814Z (about 1 year ago)
- Topics: mutex, posix, pthread, semaphore, synchronization, thread
- Language: C
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Philosophers
### « I never thought philosophy would be so deadly »
This project consists in a simulation of philosophers (each being represented by a thread) executing a simple routine: take two forks, eat, sleep and think.
The routine can be executed forever, but the simulation stops if a philosopher dies or if all the philosophers ate the specified number of meals.
Semaphores, Mutex and Barriers are also used, mainly for thread synchronisation but also to avoid data races.
Logs are displayed during the simulation, in the following format: \[actual_timestamp] \[philosopher_id] \[action].
All the paramaters of the simulation can be set by the user.
Usage: `./philo [numbers_of_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [meals_number]`
Time values are in milliseconds and can't be less than 60. Last argument is optionnal.