finish
This commit is contained in:
parent
b940b46924
commit
291c7b40b1
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/27 11:44:14 by cchauvet #+# #+# */
|
/* Created: 2023/04/27 11:44:14 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/05/02 11:41:10 by cchauvet ### ########.fr */
|
/* Updated: 2023/05/16 13:13:13 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -71,6 +71,7 @@ bool philo_eat(t_philo *philo, t_data *data)
|
|||||||
{
|
{
|
||||||
if (philo_take_forks(philo, data))
|
if (philo_take_forks(philo, data))
|
||||||
return (1);
|
return (1);
|
||||||
|
philo->last_eat = get_time();
|
||||||
print_eating(philo);
|
print_eating(philo);
|
||||||
usleep(get_time_eat(philo, data) * 1000);
|
usleep(get_time_eat(philo, data) * 1000);
|
||||||
pthread_mutex_unlock(&data->forks[philo->id]);
|
pthread_mutex_unlock(&data->forks[philo->id]);
|
||||||
@ -78,7 +79,6 @@ bool philo_eat(t_philo *philo, t_data *data)
|
|||||||
if (check(philo, data))
|
if (check(philo, data))
|
||||||
return (1);
|
return (1);
|
||||||
pthread_mutex_lock(&philo->last_eat_mutex);
|
pthread_mutex_lock(&philo->last_eat_mutex);
|
||||||
philo->last_eat = get_time();
|
|
||||||
pthread_mutex_unlock(&philo->last_eat_mutex);
|
pthread_mutex_unlock(&philo->last_eat_mutex);
|
||||||
pthread_mutex_lock(&philo->nb_meal_mutex);
|
pthread_mutex_lock(&philo->nb_meal_mutex);
|
||||||
philo->nb_meal++;
|
philo->nb_meal++;
|
||||||
|
BIN
philo_routine.o
Normal file
BIN
philo_routine.o
Normal file
Binary file not shown.
3
time.c
3
time.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/27 11:35:26 by cchauvet #+# #+# */
|
/* Created: 2023/04/27 11:35:26 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/05/02 11:44:21 by cchauvet ### ########.fr */
|
/* Updated: 2023/05/16 13:24:30 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -53,4 +53,3 @@ size_t get_time_sleep(t_philo *philo, t_data *data)
|
|||||||
value = data->sleep_time;
|
value = data->sleep_time;
|
||||||
return (value);
|
return (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
utils/ft_atoi.o
Normal file
BIN
utils/ft_atoi.o
Normal file
Binary file not shown.
BIN
utils/ft_isnum.o
Normal file
BIN
utils/ft_isnum.o
Normal file
Binary file not shown.
BIN
utils/putchar.o
Normal file
BIN
utils/putchar.o
Normal file
Binary file not shown.
BIN
utils/putnum.o
Normal file
BIN
utils/putnum.o
Normal file
Binary file not shown.
BIN
utils/putstr.o
Normal file
BIN
utils/putstr.o
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user