Compare commits
2 Commits
7e5d4af478
...
550851a5c8
Author | SHA1 | Date | |
---|---|---|---|
|
550851a5c8 | ||
|
0956af87ca |
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/27 11:44:14 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/05/16 13:13:13 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/05/24 13:38:11 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -71,15 +71,15 @@ bool philo_eat(t_philo *philo, t_data *data)
|
||||
{
|
||||
if (philo_take_forks(philo, data))
|
||||
return (1);
|
||||
pthread_mutex_lock(&philo->last_eat_mutex);
|
||||
philo->last_eat = get_time();
|
||||
pthread_mutex_unlock(&philo->last_eat_mutex);
|
||||
print_eating(philo);
|
||||
usleep(get_time_eat(philo, data) * 1000);
|
||||
pthread_mutex_unlock(&data->forks[philo->id]);
|
||||
pthread_mutex_unlock(&data->forks[(philo->id + 1) % data->nb_philos]);
|
||||
if (check(philo, data))
|
||||
return (1);
|
||||
pthread_mutex_lock(&philo->last_eat_mutex);
|
||||
pthread_mutex_unlock(&philo->last_eat_mutex);
|
||||
pthread_mutex_lock(&philo->nb_meal_mutex);
|
||||
philo->nb_meal++;
|
||||
pthread_mutex_unlock(&philo->nb_meal_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user