diff options
Diffstat (limited to 'philo_one/src')
| -rw-r--r-- | philo_one/src/event.c (renamed from philo_one/src/io.c) | 10 | ||||
| -rw-r--r-- | philo_one/src/philo_one.h | 10 | ||||
| -rw-r--r-- | philo_one/src/routine.c | 14 |
3 files changed, 17 insertions, 17 deletions
diff --git a/philo_one/src/io.c b/philo_one/src/event.c index b5bf82e..8952212 100644 --- a/philo_one/src/io.c +++ b/philo_one/src/event.c @@ -12,7 +12,7 @@ #include "philo_one.h" -void io_take_fork(t_philo *arg, pthread_mutex_t *fork) +void event_take_fork(t_philo *arg, pthread_mutex_t *fork) { pthread_mutex_lock(fork); pthread_mutex_lock(&arg->conf->mutex_stdout); @@ -22,7 +22,7 @@ void io_take_fork(t_philo *arg, pthread_mutex_t *fork) pthread_mutex_unlock(&arg->conf->mutex_stdout); } -void io_eat(t_philo *arg) +void event_eat(t_philo *arg) { int eat_counter; @@ -39,7 +39,7 @@ void io_eat(t_philo *arg) } } -void io_think(t_philo *arg) +void event_think(t_philo *arg) { pthread_mutex_lock(&arg->conf->mutex_stdout); if (!arg->conf->all_alive) @@ -48,7 +48,7 @@ void io_think(t_philo *arg) pthread_mutex_unlock(&arg->conf->mutex_stdout); } -void io_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left) +void event_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left) { pthread_mutex_lock(&arg->conf->mutex_stdout); if (!arg->conf->all_alive) @@ -60,7 +60,7 @@ void io_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_ usleep(arg->conf->timeout_sleep * 1000); } -void io_die(t_philo *arg) +void event_die(t_philo *arg) { pthread_mutex_lock(&arg->conf->mutex_stdout); if (!arg->conf->all_alive) diff --git a/philo_one/src/philo_one.h b/philo_one/src/philo_one.h index 9fc5e5f..cb41b77 100644 --- a/philo_one/src/philo_one.h +++ b/philo_one/src/philo_one.h @@ -76,10 +76,10 @@ void *routine_death(t_philo *arg); ** io.c */ -void io_take_fork(t_philo *arg, pthread_mutex_t *fork); -void io_eat(t_philo *arg); -void io_think(t_philo *arg); -void io_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left); -void io_die(t_philo *arg); +void event_take_fork(t_philo *arg, pthread_mutex_t *fork); +void event_eat(t_philo *arg); +void event_think(t_philo *arg); +void event_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left); +void event_die(t_philo *arg); #endif diff --git a/philo_one/src/routine.c b/philo_one/src/routine.c index 5f76a26..c1a7a4f 100644 --- a/philo_one/src/routine.c +++ b/philo_one/src/routine.c @@ -21,15 +21,15 @@ void *routine_philo(t_philo *arg) arg->time_last_eat = h_time_now(); if (pthread_create(&thread_death, NULL, (t_routine)routine_death, arg) != 0) return (NULL); - io_think(arg); + event_think(arg); while (arg->conf->all_alive) { - io_take_fork(arg, arg->fork_left); - io_take_fork(arg, arg->fork_right); + event_take_fork(arg, arg->fork_left); + event_take_fork(arg, arg->fork_right); arg->time_last_eat = h_time_now(); - io_eat(arg); - io_sleep(arg, arg->fork_right, arg->fork_left); - io_think(arg); + event_eat(arg); + event_sleep(arg, arg->fork_right, arg->fork_left); + event_think(arg); } pthread_join(thread_death, NULL); return (NULL); @@ -45,6 +45,6 @@ void *routine_death(t_philo *arg) current = h_time_now(); if (!arg->conf->all_alive) return (NULL); - io_die(arg); + event_die(arg); return (NULL); } |
