From 42360f381cebd6376c261b16038a7f12971f925e Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 30 Sep 2020 08:18:29 +0200 Subject: Added 'has taken fork' log, Refactoring philo_one to work with new common lib --- philo_one/src/routine.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'philo_one/src/routine.c') diff --git a/philo_one/src/routine.c b/philo_one/src/routine.c index 0115e91..1803b7d 100644 --- a/philo_one/src/routine.c +++ b/philo_one/src/routine.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/10 01:11:27 by cacharle #+# #+# */ -/* Updated: 2020/09/29 14:30:06 by cacharle ### ########.fr */ +/* Updated: 2020/09/30 08:17:21 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,14 +24,11 @@ void *routine_philo(t_routine_arg *arg) io_think(arg); while (arg->conf->all_alive) { - pthread_mutex_lock(arg->fork_left); - pthread_mutex_lock(arg->fork_right); + io_take_fork(arg, arg->fork_left); + io_take_fork(arg, arg->fork_right); arg->philo->time_last_eat = h_time_now(); io_eat(arg); - io_sleep(arg); - pthread_mutex_unlock(arg->fork_right); - pthread_mutex_unlock(arg->fork_left); - usleep(arg->conf->timeout_sleep * 1000); + io_sleep(arg, arg->fork_right, arg->fork_left); io_think(arg); } pthread_join(thread_death, NULL); -- cgit