diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 14:04:22 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 14:04:22 +0100 |
| commit | e874ad94a31a8259b8eb7ad2865767c081bcd279 (patch) | |
| tree | e629a6cef53b2c6cafcde9f8bbf5d1f7678753d6 /philo_three/src/event.c | |
| parent | 592c515b742222c637478b3339b95cd2de8b4379 (diff) | |
| download | philosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.tar.gz philosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.tar.bz2 philosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.zip | |
Fixing philo_one/philo_two dying by sleeping more when checking the death, Fixing timestamp in the wrong order in philo_three
Diffstat (limited to 'philo_three/src/event.c')
| -rw-r--r-- | philo_three/src/event.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/philo_three/src/event.c b/philo_three/src/event.c index 33b1e00..10f82c4 100644 --- a/philo_three/src/event.c +++ b/philo_three/src/event.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */ -/* Updated: 2021/01/01 16:29:31 by charles ### ########.fr */ +/* Updated: 2021/01/03 13:51:20 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,14 +16,14 @@ void event_take_fork(t_philo *philo) { sem_wait(philo->forks); sem_wait(philo->sem_stdout); - philo_put(philo->id, EVENT_FORK); + philo_put(philo->id, EVENT_FORK, philo->initial_time); sem_post(philo->sem_stdout); } void event_eat(t_philo *philo) { sem_wait(philo->sem_stdout); - philo_put(philo->id, EVENT_EAT); + philo_put(philo->id, EVENT_EAT, philo->initial_time); sem_post(philo->sem_stdout); usleep(philo->conf->timeout_eat * 1000); } @@ -31,14 +31,14 @@ void event_eat(t_philo *philo) void event_think(t_philo *philo) { sem_wait(philo->sem_stdout); - philo_put(philo->id, EVENT_THINK); + philo_put(philo->id, EVENT_THINK, philo->initial_time); sem_post(philo->sem_stdout); } void event_sleep(t_philo *philo) { sem_wait(philo->sem_stdout); - philo_put(philo->id, EVENT_SLEEP); + philo_put(philo->id, EVENT_SLEEP, philo->initial_time); sem_post(philo->sem_stdout); sem_post(philo->forks); sem_post(philo->forks); @@ -50,7 +50,7 @@ void event_die(t_philo *philo) long int i; sem_wait(philo->sem_stdout); - philo_put(philo->id, EVENT_DIE); + philo_put(philo->id, EVENT_DIE, philo->initial_time); if (philo->conf->meal_num == -1) sem_post(philo->sem_finish); else |
