droitier gaucher fonctionne, plus de lock order violated

This commit is contained in:
hugogogo
2022-01-31 18:42:00 +01:00
parent 41726f5e41
commit 2fa49b3242

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */ /* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/31 10:23:55 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) if (philo->p_nbr % 2 == 0)
{ {
fork1 = &(philo->next->m_fork); fork1 = &(philo->next->m_fork);
@@ -90,10 +94,13 @@ void *philo_exec(void *arg)
philo = (t_philo *)arg; philo = (t_philo *)arg;
init_time(philo); init_time(philo);
if (philo->p_nbr % 2 == 0)
usleep(10 * 1000);
fork1 = &(philo->m_fork); fork1 = &(philo->m_fork);
fork2 = &(philo->next->m_fork); fork2 = &(philo->next->m_fork);
if (philo->p_nbr % 2 == 0)
{
fork1 = &(philo->next->m_fork);
fork2 = &(philo->m_fork);
}
while (1) while (1)
{ {
if (eat(philo, fork1, fork2) != 0) if (eat(philo, fork1, fork2) != 0)
@@ -103,6 +110,7 @@ void *philo_exec(void *arg)
action_delay(philo, philo->params->t_slp); action_delay(philo, philo->params->t_slp);
if (print_message(philo, B_GREEN, "is thinking")) if (print_message(philo, B_GREEN, "is thinking"))
break ; break ;
usleep(1 * 1000);
} }
return (NULL); return (NULL);
} }