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_two/src/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'philo_two/src/main.c') diff --git a/philo_two/src/main.c b/philo_two/src/main.c index fb441dc..197ee5c 100644 --- a/philo_two/src/main.c +++ b/philo_two/src/main.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 22:45:23 by cacharle #+# #+# */ -/* Updated: 2021/01/09 15:35:47 by charles ### ########.fr */ +/* Updated: 2021/01/10 10:18:12 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,12 +23,17 @@ static int st_destroy( t_philo *philos, pthread_t *threads) { + /* long int i; */ + sem_unlink(PHILO_SEM_NAME); sem_unlink(PHILO_SEM_STDOUT_NAME); sem_unlink(PHILO_SEM_FINISH_NAME); sem_unlink(PHILO_SEM_MEAL_NUM_NAME); sem_unlink(PHILO_SEM_START_NAME); sem_unlink(PHILO_SEM_GRAB_NAME); + /* i = -1; */ + /* while (++i < philos[0].conf->philo_num) */ + /* sem_unlink(philo_sem_eat_name(philo[i].id)); */ free(philos); free(threads); return (1); -- cgit