Skip to content

magnitopic/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 

Repository files navigation

Philosophers 💭

In this project, you will learn the basics of threading a process. You will see how to create threads and you will discover mutexes.

Philo

Program

Initial installation and compilation

git clone https://github.com/magnitopic/philosophers.git
cd philosophers/philo
make

Usage

Note: Times are measured in milliseconds.

./philo "number_of_philos" "time_to_die" "time_to_eat" "time_to_sleep" "times_a_philo_must_eat(optional)"

Examples

Normal execution

./philo 5 800 200 200

Every philo will eat 50 times

./philo 5 800 200 200 50

Example with some tight timing

./philo 5 310 103 103

Example using pipes to count number of times eaten. 5 philos times 7 times to eat, the result should be 35 at least

./philo 5 800 200 200 7 | grep "eating" | wc -l