diff --git a/philo/philo.c b/philo/philo.c index 104ab72..ef1f173 100644 --- a/philo/philo.c +++ b/philo/philo.c @@ -6,7 +6,7 @@ /* By: narnaud@student.42nice.fr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/19 00:36:57 by narnaud@stude #+# #+# */ -/* Updated: 2022/05/19 01:41:03 by narnaud ### ########.fr */ +/* Updated: 2022/05/19 20:01:36 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,6 +40,7 @@ static int waiter(t_room *room, t_philo *philo) int ret; ret = 1; + usleep(1000); pthread_mutex_lock(room->lock); starvest = room->param[MEALS_AMOUNT]; while (ret && philo->id >= 0) diff --git a/philo/philo_init.c b/philo/philo_init.c index 0b46f85..954d97b 100644 --- a/philo/philo_init.c +++ b/philo/philo_init.c @@ -6,7 +6,7 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/24 15:44:04 by narnaud #+# #+# */ -/* Updated: 2022/05/19 01:33:29 by narnaud ### ########.fr */ +/* Updated: 2022/05/19 20:07:29 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,7 +46,6 @@ t_philo *create_philos(t_room *room) ret[i].lock = malloc(sizeof(pthread_mutex_t)); ret[i].thd = malloc(sizeof(pthread_t)); ret[i].room = room; - ret[i].eat_time = room_clock(); ret[i].eat_amount = 0; ret[i].id = i; pthread_mutex_init(ret[i].fork, NULL); @@ -63,6 +62,7 @@ void invit_philos(t_philo *philos) t_philo *philo; philo = philos; + philo->eat_time = room_clock(); room = philo->room; while (i >= 0) { @@ -77,5 +77,6 @@ void invit_philos(t_philo *philos) else if ((i % 2) == 1) i -= 2; philo = philos + i; + usleep(10); } } diff --git a/philo/philo_utils.c b/philo/philo_utils.c index 3017bbe..0971d8c 100644 --- a/philo/philo_utils.c +++ b/philo/philo_utils.c @@ -6,7 +6,7 @@ /* By: narnaud@student.42nice.fr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/18 19:10:41 by narnaud@stude #+# #+# */ -/* Updated: 2022/05/19 00:50:56 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/19 20:02:59 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,7 @@ int safe_wait(t_room *room, int start, int duration) < (start + room->param[duration]))) { ret = is_running(room); - usleep(50); + usleep(1000); } return (ret); }