Skip to content

jdecorte-be/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

philosophers philosophers

A C implementation of the classic Dining Philosophers problem. A 42 school project exploring threading, mutexes, and semaphores to solve synchronization issues.

42 School Project Focus Concurrency & Sync Problem Dining Philosophers Built with C & Pthreads

Type CLI Simulation philosophers license philosophers stars philosophers issues philosophers repo size philosophers top language

IntroductionInstallation 🖥Tips projectProject documentation 📚


Introduction

In computer science, the dining philosophers problem is an example problem often used in concurrent algorithm design to illustrate synchronization issues and techniques for resolving them.

It was originally formulated in 1965 by Edsger Dijkstra as a student exam exercise, presented in terms of computers competing for access to tape drive peripherals. Soon after, Tony Hoare gave the problem its present formulation

More informations

Tips and good methodology to do the project at the bottom of the readme

Installation 🖥

To test the project, go to one of the folders philo_one, philo_two or philo_three and make a make. Then, you can test the project using an executable.

usage :

./philo_one number_philosopher time_to_die time_to_eat time_to_sleep [number_of_time_each_philosophers_must_eat] arguments in square brackets are not required (number_of_time_each_philosophers_must_eat)

exemple :

./philo_one 4 500 200 200

I made a visual option, which makes it possible to have a prettier display, which reduces performance a little. To use it, add the option -v after the executable, this option is only available on philo_zero (philo zero is identical to philo one, but it can handle the [-v] option)

exemple :

./philo_zero -v 4 500 200 200

alt text

Tips project

⚠️ Warning: Don't copy/paste code you don't understand: it's bad for you, and for the school. I have put my login in a lot of files to encourage you doing your own version. Have fun !

Philo_one Thread and Mutex (good resolution diagram)

alt text

Project documentation 📚

Use pthread (pthread_create | pthread_join) EN video

Thread & Mutex EN video

Semaphore EN video

Fork explain in FR or Fork Wiki EN

About

A C implementation of the classic Dining Philosophers problem. A 42 school project exploring threading, mutexes, and semaphores to solve synchronization issues.

Topics

Resources

License

Stars

Watchers

Forks

Contributors