This commit is contained in:
Camille Chauvet 2023-05-05 16:59:36 +00:00
parent 5c309f2f02
commit b940b46924
2 changed files with 3 additions and 4 deletions

3
data.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:28:36 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:28:36 by cchauvet #+# #+# */
/* Updated: 2023/04/27 12:04:31 by cchauvet ### ########.fr */ /* Updated: 2023/05/05 16:58:45 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -67,6 +67,7 @@ void data_destroyer(t_data *data)
i++; i++;
usleep(1000); usleep(1000);
} }
usleep(1000);
i = -1; i = -1;
while (++i < (ssize_t) data->nb_philos) while (++i < (ssize_t) data->nb_philos)
pthread_mutex_destroy(&data->forks[i]); pthread_mutex_destroy(&data->forks[i]);

4
time.c
View File

@ -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:42:45 by cchauvet ### ########.fr */ /* Updated: 2023/05/02 11:44:21 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -39,7 +39,6 @@ size_t get_time_eat(t_philo *philo, t_data *data)
value = (data->life_expectency - philo->last_eat - time); value = (data->life_expectency - philo->last_eat - time);
if (value > data->eat_time) if (value > data->eat_time)
value = data->eat_time; value = data->eat_time;
// printf("\n%zu: time: %zu, last: %zu, eat: %zu, expectencty: %zu, value: %zu\n", philo->id + 1, time, philo->last_eat, data->eat_time, data->life_expectency, value);
return (value); return (value);
} }
@ -52,7 +51,6 @@ size_t get_time_sleep(t_philo *philo, t_data *data)
value = (data->life_expectency - (time - philo->last_eat)); value = (data->life_expectency - (time - philo->last_eat));
if (value > data->sleep_time) if (value > data->sleep_time)
value = data->sleep_time; value = data->sleep_time;
// printf("\n%zu: time: %zu, last: %zu, sleep: %zu, expectencty: %zu, value: %zu\n", philo->id + 1, time, philo->last_eat, data->sleep_time, data->life_expectency, value);
return (value); return (value);
} }