Skip to content

Matesant/Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

Imagem 1 Imagem 2

Because Eating with a Single Fork Is Too Much Trouble()

About

This project is the first one in the 42 curriculum that requires the use of threads. The goal is to simulate the Dining Philosophers problem, where multiple philosopher threads share resources (forks) to eat spaghetti. The project involves managing synchronization and preventing issues that arise with concurrent processes.

Challenges

  • Multi threads
  • Data Racing: Address and resolve issues of data races between philosopher threads.
  • Deadlocks: Prevent and handle deadlocks caused by mutexes used for resource management.
  • Philosopher Lifecycle: Implement mechanisms to monitor and manage the time philosophers spend eating and prevent them from "dying" due to starvation.

Instructions

1. Compiling the archives

To compile the project, go to its path and run:

For mandatory functions:

$ make

2. Cleaning all binary (.o) and executable files (.a)

To delete all files generated with make, go to the path and run:

$ make fclean

3. How to use

  • ./philo [Number_of_philo] [Time_to_die] [Time_to_eat] [Time_to_sleep] [OPTIONAL: Number_of_time_need_to_eat]
$ ./philo 10 800 200 200 5

Testing

This project have been tested with Nafuka Visualizer.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published