norm
This commit is contained in:
parent
61b599b9f2
commit
984f4c59bf
@ -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/24 14:03:42 by cchauvet ### ########.fr */
|
/* Updated: 2023/05/25 15:08:44 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,13 +16,6 @@
|
|||||||
#include "./print.h"
|
#include "./print.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
void philo_stop(t_philo *philo)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&philo->stop_mutex);
|
|
||||||
philo->stop = 1;
|
|
||||||
pthread_mutex_unlock(&philo->stop_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool check(t_philo *philo, t_data *data)
|
bool check(t_philo *philo, t_data *data)
|
||||||
{
|
{
|
||||||
bool stop;
|
bool stop;
|
||||||
@ -106,12 +99,14 @@ void *philo_routine(void *arg)
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (check(philo, data)
|
if (check(philo, data)
|
||||||
|| philo_eat(philo, data)
|
|| philo_eat(philo, data)
|
||||||
|| check(philo, data)
|
|| check(philo, data)
|
||||||
|| philo_sleep(data, philo)
|
|| philo_sleep(data, philo)
|
||||||
|| check(philo, data))
|
|| check(philo, data))
|
||||||
{
|
{
|
||||||
philo_stop(philo);
|
pthread_mutex_lock(&philo->stop_mutex);
|
||||||
|
philo->stop = 1;
|
||||||
|
pthread_mutex_unlock(&philo->stop_mutex);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
print_thinking(philo);
|
print_thinking(philo);
|
||||||
|
Loading…
Reference in New Issue
Block a user