This commit is contained in:
Houtworm 2023-05-24 03:08:05 +02:00
parent d5c17b48d8
commit d3d063d793

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* .--. _ */ /* .--. _ */
/* watch.c |o_o || | */ /* watch.c :+: :+: :+: */
/* |:_/ || |_ _ ___ __ */ /* |:_/ || |_ _ ___ __ */
/* By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / */ /* By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */ /* (| | )|_| |_| |> < */
/* Created: 2023/05/24 00:23:22 by djonker /'\_ _/`\__|\__,_/_/\_\ */ /* Created: 2023/05/24 00:23:22 by djonker /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/24 02:24:11 by djonker \___)=(___/ */ /* Updated: 2023/05/24 03:05:35 by houtworm ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -65,11 +65,11 @@ void *ft_alive(void *pointer)
sem_close(philo->print); sem_close(philo->print);
hold = sem_open("hold", 0); hold = sem_open("hold", 0);
print = sem_open("print", 0); print = sem_open("print", 0);
sem_wait(philo->hold); sem_wait(hold);
while (ft_time() - philo->lastfood < *philo->dietime) while (ft_time() - philo->lastfood < *philo->dietime)
usleep(500); usleep(500);
sem_post(philo->dead); sem_post(philo->dead);
sem_wait(philo->print); sem_wait(print);
if (*philo->alive) if (*philo->alive)
printf("%lld %d died\n", ft_time() - *philo->strtt, philo->id); printf("%lld %d died\n", ft_time() - *philo->strtt, philo->id);
return (NULL); return (NULL);