Skip to content

Basics of threading a process. Discovering how to create threads and mutexes.

Notifications You must be signed in to change notification settings

Uatilla/42Porto_Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

Threads, Mutexes and so on

T-4nH1-ezgif com-video-to-gif-converter

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.

How to use it

Getting Started

MasterHead You just need to download or clone this git repository. git@github.com:Uatilla/42Porto_Philosophers.git

Usage

Screencastfrom2024-10-0210-51-23-ezgif com-video-to-gif-converter

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.

Rules

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.

Sources

Contributing

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.

Welcome to my new brave world!

00100010 01000010 01100101 00100000 01110111 01100001 01110100 01100101 01110010 00100000 01101101 01111001 00100000 01100110 01110010 01101001 01100101 01101110 01100100 00100010 00100000 01000010 01110010 01110101 01100011 01100101 00100000 01001100 01100101 01100101

About me

  • 👋 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 and Sports of all kinds.
  • 🚀 Additionally, I have an interest in Blockchain, Python, Data Analysis and Machine Learning.
  • 📫 You can reach me on LinkedIn.
  • 🤔 Feeling amazing about how the blockchain technology will change our lives.

Skills

uatilla

 uatilla

uatilla

About

Basics of threading a process. Discovering how to create threads and mutexes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published