diff --git a/philo/log.c b/philo/log.c index cdd711d..3aef0de 100644 --- a/philo/log.c +++ b/philo/log.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/07 16:12:20 by adjoly #+# #+# */ -/* Updated: 2024/07/16 20:24:43 by adjoly ### ########.fr */ +/* Updated: 2024/07/21 21:31:44 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,15 +19,15 @@ void log_philo(uint32_t timestamp, t_philo philo) static pthread_mutex_t print = {0}; pthread_mutex_lock(&print); - if (philo->state == EAT) - printf("%u %hu %s", timestamp, philo->nbr, EATING_MSG); - else if (philo->state == THINK) - printf("%u %hu %s", timestamp, philo->nbr, THINK_MSG); - else if (philo->state == SLEEP) - printf("%u %hu %s", timestamp, philo->nbr, SLEEP_MSG); - else if (philo->state == DIED) - printf("%u %hu %s", timestamp, philo->nbr, DIED_MSG); - else if (philo->state == FORK_TAKEN) - printf("%u %hu %s", timestamp, philo->nbr, FORK_MSG); + if (philo.state == EAT) + printf("%u %hu %s", timestamp, philo.nbr, EATING_MSG); + else if (philo.state == THINK) + printf("%u %hu %s", timestamp, philo.nbr, THINK_MSG); + else if (philo.state == SLEEP) + printf("%u %hu %s", timestamp, philo.nbr, SLEEP_MSG); + else if (philo.state == DIED) + printf("%u %hu %s", timestamp, philo.nbr, DIED_MSG); + else if (philo.state == FORK_TAKEN) + printf("%u %hu %s", timestamp, philo.nbr, FORK_MSG); pthread_mutex_unlock(&print); } diff --git a/philo/parsing.c b/philo/parsing.c index c2d2c48..9f4aa14 100644 --- a/philo/parsing.c +++ b/philo/parsing.c @@ -1,17 +1,16 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* parse_argv.c :+: :+: :+: */ +/* parsing.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/08 15:30:46 by adjoly #+# #+# */ -/* Updated: 2024/07/09 10:46:47 by adjoly ### ########.fr */ +/* Updated: 2024/07/21 21:23:35 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "philo.h" -#include "utils.h" t_pdata fill_pdata(char **av) { diff --git a/philo/philo.h b/philo/philo.h index 967eadc..6092cf5 100644 --- a/philo/philo.h +++ b/philo/philo.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/07 15:11:02 by adjoly #+# #+# */ -/* Updated: 2024/07/18 18:30:56 by adjoly ### ########.fr */ +/* Updated: 2024/07/21 21:55:26 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,18 +53,23 @@ typedef struct s_philo t_fork fork; t_pstate state; t_pdata data; - pthread_t thread; } t_philo; +typedef struct s_init +{ + pthread_t thread; + t_philo data; +} t_init; + /** * Utils */ -void log_philo(uint32_t timestamp, uint16_t philo, t_pstate type); +void log_philo(uint32_t timestamp, t_philo philo); t_pdata philo_parse(char **argv, int ac); long long ft_atoll(const char *nptr); uint16_t get_time_in_ms(struct timeval t0, struct timeval t1); -void *philo_routine(void *param) +void *philo_routine(void *param); /** * Main path * by order of call