gestion cas n_eat a zero
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/01/26 15:30:49 by hulamy #+# #+# */
|
||||
/* Updated: 2022/01/26 16:29:13 by hulamy ### ########.fr */
|
||||
/* Updated: 2022/01/26 18:52:32 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -36,17 +36,31 @@ static int is_finished(t_philo *philo, struct timeval *stime)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int is_satiated(t_philo *philo)
|
||||
{
|
||||
if (philo->eat_count == philo->params->n_eat)
|
||||
{
|
||||
philo->global->satiated_count++;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void pere_fouettard(t_philo *philo)
|
||||
{
|
||||
struct timeval stime;
|
||||
int i;
|
||||
int satiated;
|
||||
|
||||
while (philo->global->stop == 0)
|
||||
{
|
||||
i = 0;
|
||||
satiated = 1;
|
||||
gettimeofday(&stime, NULL);
|
||||
while (i < philo->params->n_phi)
|
||||
{
|
||||
if (satiated == 1 && is_satiated(philo) == 0)
|
||||
satiated = 0;
|
||||
if (is_finished(philo, &stime))
|
||||
break ;
|
||||
philo = philo->next;
|
||||
|
||||
Reference in New Issue
Block a user