From 619ebba469369b3bcda5d302fcff2978c614d057 Mon Sep 17 00:00:00 2001 From: djonker Date: Tue, 23 May 2023 04:05:44 +0200 Subject: [PATCH] done --- philo_bonus/src/philo.c | 7 ++++--- philo_bonus/src/watch.c | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/philo_bonus/src/philo.c b/philo_bonus/src/philo.c index 24f6332..3457ac9 100644 --- a/philo_bonus/src/philo.c +++ b/philo_bonus/src/philo.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* .--. _ */ -/* philo.c :+: :+: :+: */ +/* philo.c |o_o || | */ /* |:_/ || |_ _ ___ __ */ /* By: houtworm // \ \ __| | | \ \/ / */ /* (| | )|_| |_| |> < */ /* Created: 2023/03/11 06:42:31 by houtworm /'\_ _/`\__|\__,_/_/\_\ */ -/* Updated: 2023/05/22 08:10:48 by houtworm ### ########.fr */ +/* Updated: 2023/05/23 04:03:02 by houtworm \___)=(___/ */ /* */ /* ************************************************************************** */ @@ -65,8 +65,8 @@ int ft_startcycle(t_strct *st) st->strtt = ft_time(); while (i < st->philos) { - st->pid[i] = fork(); st->alive = 1; + st->pid[i] = fork(); if (st->pid[i] == 0) { st->philo[i].alive = &st->alive; @@ -102,6 +102,7 @@ int main(int argc, char **argv) } i = ft_initstructandmutex(strct, 0); ft_startcycle(strct); + usleep(1000); strct->pid[501] = fork(); if (strct->pid[501] == 0) ft_waitingfordeath(strct); diff --git a/philo_bonus/src/watch.c b/philo_bonus/src/watch.c index ede155e..7df80aa 100644 --- a/philo_bonus/src/watch.c +++ b/philo_bonus/src/watch.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* watch.c :+: :+: :+: */ +/* watch.c |o_o || | */ /* +:+ +:+ +:+ */ /* By: houtworm +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/05/22 07:34:59 by houtworm #+# #+# */ -/* Updated: 2023/05/23 03:07:31 by houtworm ### ########.fr */ +/* Updated: 2023/05/23 04:04:00 by houtworm \___)=(___/ */ /* */ /* ************************************************************************** */ @@ -19,8 +19,8 @@ int ft_releasetheminds(t_strct *strct, int m) i = 0; if (m) { - strct->strtt = ft_time(); - while (i < strct->philos) + /*strct->strtt = ft_time();*/ + while (i < (strct->philos * 2) - 1) { sem_post(strct->hold); i++; @@ -76,7 +76,8 @@ void *ft_alive(void *pointer) t_philo *philo; philo = pointer; - usleep(*philo->dietime); + /*usleep(*philo->dietime);*/ + sem_wait(philo->hold); while (ft_time() - philo->lastfood < *philo->dietime) usleep(500); sem_post(philo->dead);