diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-14 01:42:10 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-14 01:42:10 +0100 |
| commit | adbe9cdb61e5d12299b8872b2ac27a48036bc95d (patch) | |
| tree | e8c5028c2f813ae4ee37b741f9b0a0d83af9e6f3 /philo_one/philo.c | |
| parent | 1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642 (diff) | |
| download | philosophers-adbe9cdb61e5d12299b8872b2ac27a48036bc95d.tar.gz philosophers-adbe9cdb61e5d12299b8872b2ac27a48036bc95d.tar.bz2 philosophers-adbe9cdb61e5d12299b8872b2ac27a48036bc95d.zip | |
WIP: philo_one running a bit
Diffstat (limited to 'philo_one/philo.c')
| -rw-r--r-- | philo_one/philo.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/philo_one/philo.c b/philo_one/philo.c index 7cc3ca4..c585e34 100644 --- a/philo_one/philo.c +++ b/philo_one/philo.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/02/10 01:29:25 by cacharle ### ########.fr */ +/* Updated: 2020/02/14 01:38:45 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,14 +40,13 @@ void philos_destroy(t_philo *philos, int num) t_bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) { - t_routine_arg *routine_arg; int i; i = -1; while (++i < num) { philos[i].alive = TRUE; - if (pthread_create(philos[i].thread, NULL, philo_one_routine, (void*)(routine_args + i)) == -1) + if (pthread_create(&philos[i].thread, NULL, &routine_philo, (void*)(routine_args + i)) == -1) return (FALSE); } return (TRUE); @@ -63,7 +62,7 @@ void philos_join(t_philo *philos, int num) if (philos[i].alive) { philos[i].alive = FALSE; - pthread_join(philos[i].thread, NULL); + /* pthread_join(philos[i].thread, NULL); */ } } } @@ -74,6 +73,7 @@ t_bool philos_starved(t_philo *philos, int num) i = -1; while (++i < num) + { if (!philos[i].alive) { i = -1; @@ -81,5 +81,6 @@ t_bool philos_starved(t_philo *philos, int num) philos[i].alive = FALSE; return (TRUE); } + } return (FALSE); } |
