diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-09 16:07:01 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-09 16:07:01 +0100 |
| commit | 802ea8347d1ceb7a02cf279359b3b101106fab94 (patch) | |
| tree | 3f8b38056e29d94a813351fb99cc911d89f8df3d /philo_three/src/child.c | |
| parent | ebbd81e4312d945b359d2761acfeb613da1f98c8 (diff) | |
| download | philosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.tar.gz philosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.tar.bz2 philosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.zip | |
Added separate thread to check if max meal num is reached independent from philosopher death
Diffstat (limited to 'philo_three/src/child.c')
| -rw-r--r-- | philo_three/src/child.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/philo_three/src/child.c b/philo_three/src/child.c index 144f7ba..641b82d 100644 --- a/philo_three/src/child.c +++ b/philo_three/src/child.c @@ -6,7 +6,7 @@ /* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/30 14:36:16 by cacharle #+# #+# */ -/* Updated: 2021/01/08 20:52:22 by charles ### ########.fr */ +/* Updated: 2021/01/09 15:59:00 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,7 @@ void st_child_loop(t_philo *philo) if (philo->conf->meal_num != -1 && eat_counter == philo->conf->meal_num) { sem_wait(philo->sem_stdout); - sem_post(philo->sem_finish); + sem_post(philo->sem_meal_num); sem_post(philo->sem_stdout); } event_sleep(philo); @@ -63,6 +63,7 @@ pid_t child_start(t_philo *philo) philo->forks = sem_open(PHILO_SEM_NAME, 0); philo->sem_stdout = sem_open(PHILO_SEM_STDOUT_NAME, 0); philo->sem_finish = sem_open(PHILO_SEM_FINISH_NAME, 0); + philo->sem_meal_num = sem_open(PHILO_SEM_MEAL_NUM_NAME, 0); philo->sem_start = sem_open(PHILO_SEM_START_NAME, 0); philo->sem_grab = sem_open(PHILO_SEM_GRAB_NAME, 0); philo->time_last_eat = h_time_now(); |
