Skip to content

RochBlondiaux/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

philosophers

42 philosophers development repository.
I never thought philosophy would be so deadly

GitHub code size in bytes Number of lines of code Code language count GitHub top language GitHub last commit


🗣️ About

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

📑 Index

@root

@/srcs/main.c

  • int main(int argc, char **argv) - A rly cool functions.
  • static int launch_eat_monitor_thread(t_app *app) - A rly cool functions.
  • void init(t_philosopher *philosopher) - A rly cool functions.
  • static void check(t_app *app, t_philosopher *philosopher) - A rly cool functions.

@/srcs/utils/utils.c

  • int should_be_dead(t_philosopher *philosopher) - A rly cool functions.
  • long long get_time(void) - A rly cool functions.

@/srcs/utils/parsing_utils.c

  • int ft_atoi(char *str) - A rly cool functions.
  • int is_number(char *a) - A rly cool functions.

@/srcs/threads/thread_validator.c

  • int validate_thread(int code) - A rly cool functions.

@/srcs/philosophers/state.c

  • int is_state(t_philosopher *philosopher, t_philosopher_state state) - A rly cool functions.
  • void set_state(t_philosopher *philosopher, t_philosopher_state state) - A rly cool functions.

@/srcs/philosophers/new.c

  • void create_philosophers(t_app *app) - A rly cool functions.
  • void start(t_app *app) - A rly cool functions.
  • static void create_forks(t_app *app) - A rly cool functions.
  • static t_philosopher *create_philosopher(t_app *app, int index) - A rly cool functions.

@/srcs/philosophers/live.c

  • void *live(void *arg) - A rly cool functions.
  • static int launch_monitor_thread(t_philosopher *philosopher) - A rly cool functions.
  • static void *monitor(void *arg) - A rly cool functions.
  • void *eat_monitor(void *arg) - A rly cool functions.

@/srcs/philosophers/fork.c

  • void clear_forks(t_philosopher *philosopher) - A rly cool functions.
  • void take_forks(t_philosopher *philosopher) - A rly cool functions.

@/srcs/philosophers/eat.c

  • void eat(t_philosopher *philosopher) - A rly cool functions.

@/srcs/philosophers/clear.c

  • void clear_philosophers(t_app *app) - A rly cool functions.

@/srcs/parsing/parse.c

  • void parse_settings(t_settings *settings, int argc, char **argv) - A rly cool functions.
  • static void set_setting(t_settings *settings, int key, int value) - A rly cool functions.
  • int validate_settings(t_settings settings) - A rly cool functions.

🛠️ Usage

Requirements

The function is written in C language and thus needs the gcc compiler and some standard C libraries to run.

Instructions

1. Installation

In order to install the philosophers, you need to clone it:

git clone https://github.com/RochBlondiaux/philosophers.git && cd philosophers

Then, compile it with:

make

2. Usage

It's really simple, you just have to execute this command:

./philo <count> <die> <eat> <sleep> [times_each_must_eat]

About

42 philosophers project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published