From 2fa49b3242c01f3d6b21152c0ea0d308b56ff5da Mon Sep 17 00:00:00 2001 From: hugogogo Date: Mon, 31 Jan 2022 18:42:00 +0100 Subject: [PATCH] droitier gaucher fonctionne, plus de lock order violated --- philo/srcs/exec.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/philo/srcs/exec.c b/philo/srcs/exec.c index a7319be..792644c 100644 --- a/philo/srcs/exec.c +++ b/philo/srcs/exec.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/01/31 10:23:55 by hulamy #+# #+# */ -/* Updated: 2022/01/31 10:25:02 by hulamy ### ########.fr */ +/* Updated: 2022/01/31 18:07:43 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -76,6 +76,10 @@ static int eat(t_philo *philo, t_mtx *fork1, t_mtx *fork2) } /* +// offset launch : + if (philo->p_nbr % 2 == 0) + usleep(10 * 1000); +// righty / lefty : if (philo->p_nbr % 2 == 0) { fork1 = &(philo->next->m_fork); @@ -90,10 +94,13 @@ void *philo_exec(void *arg) philo = (t_philo *)arg; init_time(philo); - if (philo->p_nbr % 2 == 0) - usleep(10 * 1000); fork1 = &(philo->m_fork); fork2 = &(philo->next->m_fork); + if (philo->p_nbr % 2 == 0) + { + fork1 = &(philo->next->m_fork); + fork2 = &(philo->m_fork); + } while (1) { if (eat(philo, fork1, fork2) != 0) @@ -103,6 +110,7 @@ void *philo_exec(void *arg) action_delay(philo, philo->params->t_slp); if (print_message(philo, B_GREEN, "is thinking")) break ; + usleep(1 * 1000); } return (NULL); }