diff --git a/philo/headers/philo.h b/philo/headers/philo.h index 1e2bd62..5a695ae 100644 --- a/philo/headers/philo.h +++ b/philo/headers/philo.h @@ -6,7 +6,7 @@ /* By: umeneses +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/17 16:04:11 by umeneses #+# #+# */ -/* Updated: 2024/10/30 16:29:38 by umeneses ### ########.fr */ +/* Updated: 2024/10/30 16:40:57 by umeneses ### ########.fr */ /* */ /* ************************************************************************** */ @@ -148,7 +148,8 @@ void printer_with_mutex_debug(t_philo_status status, t_philo *philo, bool debbug /* dinner routines functions */ void let_philo_eat_routine(t_philo *philo); -void let_think_routine(t_philo *philo); +void let_philo_think_routine(t_philo *philo); +void let_philo_sleep_routine(t_philo *philo); /* LIBFT utility functions */ int ft_strlen(const char *str); diff --git a/philo/src/08.dinner_manager.c b/philo/src/08.dinner_manager.c index a875833..a459596 100644 --- a/philo/src/08.dinner_manager.c +++ b/philo/src/08.dinner_manager.c @@ -6,7 +6,7 @@ /* By: umeneses +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/29 10:01:45 by umeneses #+# #+# */ -/* Updated: 2024/10/30 16:29:27 by umeneses ### ########.fr */ +/* Updated: 2024/10/30 16:39:45 by umeneses ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,7 +58,7 @@ void dinner_startup_runner(t_table *table) if (table->philo->full) // TODO: thread safe break ; let_philo_eat_routine(table->philo); - let_think_routine(table->philo); - // let_sleep_routine(table->philo); // TODO + let_philo_think_routine(table->philo); + let_philo_sleep_routine(table->philo); } } diff --git a/philo/src/12.dinner_routines.c b/philo/src/12.dinner_routines.c index 1400bba..e4d5ed0 100644 --- a/philo/src/12.dinner_routines.c +++ b/philo/src/12.dinner_routines.c @@ -6,7 +6,7 @@ /* By: umeneses +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/30 16:19:23 by umeneses #+# #+# */ -/* Updated: 2024/10/30 16:37:26 by umeneses ### ########.fr */ +/* Updated: 2024/10/30 16:41:36 by umeneses ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,9 +30,15 @@ void let_philo_eat_routine(t_philo *philo) safe_mutex_handler(&philo->second_chops->chops_mtx, UNLOCK); } -void let_think_routine(t_philo *philo) +void let_philo_think_routine(t_philo *philo) { printer_with_mutex(THINKING, philo, false); // safe_mutex_handler(philo->philo_mtx, LOCK); // safe_mutex_handler(philo->philo_mtx, UNLOCK); } + +void let_philo_sleep_routine(t_philo *philo) +{ + printer_with_mutex(SLEEPING, philo, false); + precise_usleep(philo->table->set->time_to_sleep, philo->table); +}