「🏗️」 wip: testing things, might broke.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/22 21:24:53 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/23 18:07:56 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/25 16:12:00 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,16 +16,28 @@
|
||||
void *philo_routine(void *content)
|
||||
{
|
||||
t_philo philo;
|
||||
// struct timeval t1;
|
||||
bool death;
|
||||
int i = 0;
|
||||
|
||||
philo = *(t_philo *)content;
|
||||
printf("\t\t%hu\n", philo.nbr);
|
||||
//print_philo_data(philo.data);
|
||||
// while (1)
|
||||
// {
|
||||
// gettimeofday(&t1, NULL);
|
||||
// log_philo(t1, philo);
|
||||
// sleep_phil(philo.data.eat_time);
|
||||
// }
|
||||
gettimeofday(&(philo.t0), NULL);
|
||||
while (i < philo.data.meal_nbr)
|
||||
{
|
||||
philo.state = EAT;
|
||||
pthread_mutex_lock(&philo.fork.left);
|
||||
pthread_mutex_lock(philo.fork.right);
|
||||
log_philo(philo);
|
||||
death = sleep_phil(philo.data.eat_time, philo.check);
|
||||
if (death == true)
|
||||
return (NULL);
|
||||
philo.state = SLEEP;
|
||||
log_philo(philo);
|
||||
death = sleep_phil(philo.data.sleep_time, philo.check);
|
||||
if (death == true)
|
||||
return (NULL);
|
||||
philo.state = THINK;
|
||||
log_philo(philo);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user