diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-30 08:18:29 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-30 08:18:29 +0200 |
| commit | 42360f381cebd6376c261b16038a7f12971f925e (patch) | |
| tree | 729473f216fc1627fd0a7af0252160897d677a0e /philo_one/src/philo.c | |
| parent | d7aea773431926cefb6430b948329da1662d1dee (diff) | |
| download | philosophers-42360f381cebd6376c261b16038a7f12971f925e.tar.gz philosophers-42360f381cebd6376c261b16038a7f12971f925e.tar.bz2 philosophers-42360f381cebd6376c261b16038a7f12971f925e.zip | |
Added 'has taken fork' log, Refactoring philo_one to work with new common lib
Diffstat (limited to 'philo_one/src/philo.c')
| -rw-r--r-- | philo_one/src/philo.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/philo_one/src/philo.c b/philo_one/src/philo.c index e0ecfec..3e21490 100644 --- a/philo_one/src/philo.c +++ b/philo_one/src/philo.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/09/29 13:29:49 by cacharle ### ########.fr */ +/* Updated: 2020/09/30 08:10:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,10 +23,7 @@ t_philo *philos_new(int num) return (NULL); i = -1; while (++i < num) - { philos[i].id = i + 1; - philos[i].alive = false; - } return (philos); } @@ -37,7 +34,6 @@ bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) 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); @@ -45,17 +41,13 @@ bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) return (true); } -void philos_join(t_philo *philos, int num) +void philos_detach(t_philo *philos, int num) { int i; i = -1; while (++i < num) { - if (philos[i].alive) - { - philos[i].alive = false; - pthread_detach(philos[i].thread); - } + pthread_detach(philos[i].thread); } } |
