Compare commits
3 Commits
1461285dbf
...
cb2e29d18b
Author | SHA1 | Date | |
---|---|---|---|
|
cb2e29d18b | ||
|
0ae80bdcca | ||
|
e7a85b4d9d |
1
data.c
1
data.c
@ -49,6 +49,7 @@ void data_destroyer(t_data *data)
|
|||||||
pthread_mutex_unlock(&philo->stop_mutex);
|
pthread_mutex_unlock(&philo->stop_mutex);
|
||||||
if (stop)
|
if (stop)
|
||||||
i++;
|
i++;
|
||||||
|
usleep(1000);
|
||||||
}
|
}
|
||||||
pthread_mutex_destroy(&data->forks_mutex);
|
pthread_mutex_destroy(&data->forks_mutex);
|
||||||
pthread_mutex_destroy(&data->stop_mutex);
|
pthread_mutex_destroy(&data->stop_mutex);
|
||||||
|
6
main.c
6
main.c
@ -43,7 +43,7 @@ void stop(t_data *data)
|
|||||||
pthread_mutex_unlock(&data->stop_mutex);
|
pthread_mutex_unlock(&data->stop_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_routine(t_data *data)
|
void *check_routine(t_data *data)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -55,7 +55,7 @@ void check_routine(t_data *data)
|
|||||||
{
|
{
|
||||||
stop(data);
|
stop(data);
|
||||||
printf("g pu faim\n");
|
printf("g pu faim\n");
|
||||||
return ;
|
return (NULL);
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < data->nb_philos)
|
while (i < data->nb_philos)
|
||||||
@ -68,7 +68,7 @@ void check_routine(t_data *data)
|
|||||||
{
|
{
|
||||||
print_died(philo);
|
print_died(philo);
|
||||||
stop(data);
|
stop(data);
|
||||||
return ;
|
return (NULL);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
2
print.c
2
print.c
@ -19,7 +19,7 @@ static void print(t_data *data, size_t id, char *str)
|
|||||||
pthread_mutex_unlock(&data->stop_mutex);
|
pthread_mutex_unlock(&data->stop_mutex);
|
||||||
time = get_time();
|
time = get_time();
|
||||||
pthread_mutex_lock(&print_mutex);
|
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);
|
pthread_mutex_unlock(&print_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user