|
@ -6,7 +6,7 @@ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* Created: 2021/11/24 15:44:04 by narnaud #+# #+# */ |
|
|
/* Created: 2021/11/24 15:44:04 by narnaud #+# #+# */ |
|
|
/* Updated: 2022/05/19 01:33:29 by narnaud ### ########.fr */ |
|
|
/* Updated: 2022/05/19 20:07:29 by narnaud@stude ### ########.fr */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
|
@ -46,7 +46,6 @@ t_philo *create_philos(t_room *room) |
|
|
ret[i].lock = malloc(sizeof(pthread_mutex_t)); |
|
|
ret[i].lock = malloc(sizeof(pthread_mutex_t)); |
|
|
ret[i].thd = malloc(sizeof(pthread_t)); |
|
|
ret[i].thd = malloc(sizeof(pthread_t)); |
|
|
ret[i].room = room; |
|
|
ret[i].room = room; |
|
|
ret[i].eat_time = room_clock(); |
|
|
|
|
|
ret[i].eat_amount = 0; |
|
|
ret[i].eat_amount = 0; |
|
|
ret[i].id = i; |
|
|
ret[i].id = i; |
|
|
pthread_mutex_init(ret[i].fork, NULL); |
|
|
pthread_mutex_init(ret[i].fork, NULL); |
|
@ -63,6 +62,7 @@ void invit_philos(t_philo *philos) |
|
|
t_philo *philo; |
|
|
t_philo *philo; |
|
|
|
|
|
|
|
|
philo = philos; |
|
|
philo = philos; |
|
|
|
|
|
philo->eat_time = room_clock(); |
|
|
room = philo->room; |
|
|
room = philo->room; |
|
|
while (i >= 0) |
|
|
while (i >= 0) |
|
|
{ |
|
|
{ |
|
@ -77,5 +77,6 @@ void invit_philos(t_philo *philos) |
|
|
else if ((i % 2) == 1) |
|
|
else if ((i % 2) == 1) |
|
|
i -= 2; |
|
|
i -= 2; |
|
|
philo = philos + i; |
|
|
philo = philos + i; |
|
|
|
|
|
usleep(10); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|