Compare commits

...

3 Commits

Author SHA1 Message Date
Camille Chauvet
cb2e29d18b prepare to add a verif thread 2023-04-19 14:51:01 +00:00
Camille Chauvet
0ae80bdcca fix: helgreind 2023-04-19 14:49:48 +00:00
Camille Chauvet
e7a85b4d9d change display id '1' -> '001' 2023-04-19 14:49:03 +00:00
3 changed files with 5 additions and 4 deletions

1
data.c
View File

@ -49,6 +49,7 @@ void data_destroyer(t_data *data)
pthread_mutex_unlock(&philo->stop_mutex);
if (stop)
i++;
usleep(1000);
}
pthread_mutex_destroy(&data->forks_mutex);
pthread_mutex_destroy(&data->stop_mutex);

6
main.c
View File

@ -43,7 +43,7 @@ void stop(t_data *data)
pthread_mutex_unlock(&data->stop_mutex);
}
void check_routine(t_data *data)
void *check_routine(t_data *data)
{
size_t i;
bool ok;
@ -55,7 +55,7 @@ void check_routine(t_data *data)
{
stop(data);
printf("g pu faim\n");
return ;
return (NULL);
}
i = 0;
while (i < data->nb_philos)
@ -68,7 +68,7 @@ void check_routine(t_data *data)
{
print_died(philo);
stop(data);
return ;
return (NULL);
}
i++;
}

View File

@ -19,7 +19,7 @@ static void print(t_data *data, size_t id, char *str)
pthread_mutex_unlock(&data->stop_mutex);
time = get_time();
pthread_mutex_lock(&print_mutex);
printf("%07zu %3zu %s\n", time, id + 1, str);
printf("%07zu %03zu %s\n", time, id + 1, str);
pthread_mutex_unlock(&print_mutex);
}