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/routine.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/routine.c')
| -rw-r--r-- | philo_one/src/routine.c | 11 |
1 files changed, 4 insertions, 7 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); |
