From eb2cfb574efafcf2c3c6200d1cd2de700ec8ddfb Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 10 Jan 2021 10:54:04 +0100 Subject: Fixing bad performance at school by adding more delay to the death checking loop, Added mutex/semaphore to protect against eating and dying at the same time --- philo_one/src/philo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'philo_one/src/philo.c') diff --git a/philo_one/src/philo.c b/philo_one/src/philo.c index 911f6b9..8a41fe7 100644 --- a/philo_one/src/philo.c +++ b/philo_one/src/philo.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2021/01/09 14:39:03 by charles ### ########.fr */ +/* Updated: 2021/01/10 09:49:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,6 +30,7 @@ t_philo *philos_new(t_philo_conf *conf, pthread_mutex_t *forks) philos[i].fork_right = forks + (i + 1) % conf->philo_num; pthread_mutex_init(&philos[i].mutex_start, NULL); pthread_mutex_lock(&philos[i].mutex_start); + pthread_mutex_init(&philos[i].mutex_eat, NULL); } return (philos); } -- cgit