1
0

✏️」 norm: normed project.

This commit is contained in:
2024-08-20 15:44:33 +02:00
parent d820f6e64a
commit fe2d98005b
3 changed files with 14 additions and 13 deletions

View File

@ -6,12 +6,20 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/12 12:13:35 by adjoly #+# #+# */
/* Updated: 2024/08/19 23:19:17 by adjoly ### ########.fr */
/* Updated: 2024/08/20 15:43:56 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
bool unlock_death(t_philo *philo, uint8_t i)
{
pthread_mutex_unlock(philo->check);
pthread_mutex_unlock(&philo[i].fork.left);
pthread_mutex_unlock(philo[i].fork.right);
return (print_death(&philo[i]));
}
bool philo_check(t_philo *philo, t_pdata data)
{
uint8_t i;
@ -22,19 +30,13 @@ bool philo_check(t_philo *philo, t_pdata data)
eaten = 0;
while (i < data.philo_nbr)
{
gettimeofday(&t1, NULL);
pthread_mutex_lock(philo->check);
if (get_time_in_ms(philo[i].eat, t1) > data.die_time + 1)
{
pthread_mutex_unlock(philo->check);
pthread_mutex_unlock(&philo[i].fork.left);
pthread_mutex_unlock(philo[i].fork.right);
return (print_death(&philo[i]));
}
pthread_mutex_unlock(philo->check);
return (unlock_death(philo, i));
if (philo[i].meal_left == 0)
eaten++;
pthread_mutex_unlock(philo->check);
if (get_death(philo, RETURN))
return (true);
i++;

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/08 15:30:46 by adjoly #+# #+# */
/* Updated: 2024/08/13 10:32:25 by adjoly ### ########.fr */
/* Updated: 2024/08/20 15:44:22 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -54,7 +54,6 @@ t_pdata meal_nb(char **av, t_pdata data)
return (data);
}
t_pdata fill_pdata(char **av)
{
t_pdata data;

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/07 15:11:02 by adjoly #+# #+# */
/* Updated: 2024/08/12 19:04:16 by adjoly ### ########.fr */
/* Updated: 2024/08/20 15:44:09 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */