Threads, Mutexes and so on
Philosophers is a C project developed as part of the 42 School Common Core Program. The primary objective of this project is to create a program that effectively manages data races and avoid deadlocks. Just as in economics, where resources are finite and must be allocated wisely, programming requires careful management of resources—typically data—that need to be accessed by multiple processes or threads. It is essential to ensure that this data remains accurate and reliable. In this context, mutexes are employed to lock the data, preventing concurrent access and ensuring its integrity.
Threads
are essentially separate flows of execution within a program that can run concurrently, allowing a program to perform multiple tasks simultaneously. The core of this project is to teach how different threads should deal with shared resources forks
, being able to access, update, and read some content in sync, avoiding deadlocks (when each thread/flow of execution
has only part of the resources needed and the program can't proceed). For that, we were invited to solve the "Dining Philosophers" problem. You can check more about the problem here: link.
For more detailed information, look at the subject of this project.
You just need to download or clone this git repository.
git@github.com:Uatilla/42Porto_Philosophers.git
If you want to run the project yourself:
- First clone this git repository to your machine.
- Enter the repo and run ``` make ```
- Run ./philo <number_of_philosophers> <time_to_die> <time_to_eat> <time_to_sleep> [number_of_times_each_philosopher_must_eat]
Argument | Rule |
---|---|
number_of_philosophers | 0 < 200 |
time_to_die | > 60 |
time_to_eat | > 60 |
time_to_sleep | > 60 |
[number_of_times_each_philosopher_must_eat] | > 0 |
- To delete all files built except the library you can run:
make clean
. - To delete all files built including the library you can run:
make fclean
. - To delete all .o files, library, and rebuild the files to run the program again, run:
make re
.
Norminette:
The Norminette is a tool provided by 42 Network to check whether the source code complies with the school's norm. The rules include the prohibition of ‘for’ loops, a limit of 25 lines, and no more than 4 parameters in each function, among other specifications.
Here is a link to more details about what is evaluated by the Norminette tool.
Contributions to the project are welcome! If you have any ideas, improvements, or bug fixes, please submit them as issues or pull requests to this repository.
- 👋 I'm
Uatilla Viana Almeida
. - 🌱 I'm currently studying Common Core at 42 Porto after successfully completing the Piscine.
- 👀 I'm interested in
Bitcoin
,Macroeconomy
,Adventure
andSports
of all kinds. - 🚀 Additionally, I have an interest in
Blockchain
,Python
,Data Analysis
andMachine Learning
. - 📫 You can reach me on LinkedIn.
- 🤔 Feeling amazing about how the blockchain technology will change our lives.