From 6bfcd3c6f921e7717e61167b291bb27bd3f66386 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 29 Sep 2020 14:56:27 +0200 Subject: Fixing taking none existing fork in logs --- philo_one/philo.c | 61 ------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 philo_one/philo.c (limited to 'philo_one/philo.c') diff --git a/philo_one/philo.c b/philo_one/philo.c deleted file mode 100644 index c32dc76..0000000 --- a/philo_one/philo.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* philo.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/09/27 10:42:25 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "philo_one.h" - -t_philo *philos_new(int num) -{ - int i; - t_philo *philos; - - if (num < 0) - return (NULL); - if ((philos = malloc(num * sizeof(t_philo))) == NULL) - return (NULL); - i = -1; - while (++i < num) - { - philos[i].id = i + 1; - philos[i].alive = false; - } - return (philos); -} - -bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) -{ - int i; - - i = -1; - while (++i < num) - { - philos[i].alive = true; - if (pthread_create(&philos[i].thread, NULL, - (void *(*)(void*))routine_philo, (void*)(routine_args + i)) == -1) - return (false); - } - return (true); -} - -void philos_join(t_philo *philos, int num) -{ - int i; - - i = -1; - while (++i < num) - { - if (philos[i].alive) - { - philos[i].alive = false; - pthread_join(philos[i].thread, NULL); - } - } -} -- cgit