Editing to be normed \!
This commit is contained in:
parent
501b45d763
commit
3d145fb1e3
6 changed files with 17 additions and 25 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2024/07/18 18:51:45 by rparodi ### ########.fr #
|
||||
# Updated: 2024/07/18 20:55:39 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ RM = rm -rf
|
|||
# Flags
|
||||
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD
|
||||
|
||||
# CFLAGS += -fsanitize=thread
|
||||
CFLAGS += -fsanitize=thread
|
||||
|
||||
INCLUDES = ./includes/philo.h \
|
||||
./includes/types.h
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/04 11:34:04 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/04 14:11:50 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/18 21:17:07 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,21 +6,22 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/10 00:23:09 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/18 19:29:14 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/18 21:11:30 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/philo.h"
|
||||
#include <pthread.h>
|
||||
|
||||
void ft_logs(t_str msg, t_philo *philo)
|
||||
{
|
||||
t_usize time;
|
||||
|
||||
pthread_mutex_lock(philo->dead_lock);
|
||||
if (philo->dead_check == true)
|
||||
return ((void) pthread_mutex_unlock(philo->dead_lock));
|
||||
pthread_mutex_unlock(philo->dead_lock);
|
||||
pthread_mutex_lock(philo->print_lock);
|
||||
const t_usize time = ft_time() - philo->start_time;
|
||||
time = ft_time() - philo->start_time;
|
||||
if (msg != NULL)
|
||||
{
|
||||
printf("%s%zu %s%i %s%s%s", BLUE, time, GOLD, philo->id, \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/04 11:30:25 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/18 19:59:24 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/18 21:07:01 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,9 +19,6 @@ void *ft_routine(void *ptr)
|
|||
philo = (t_philo *) ptr;
|
||||
if (philo == NULL)
|
||||
return (NULL);
|
||||
pthread_mutex_lock(philo->print_lock);
|
||||
printf("\n\nEntre dans ft_routine\n\n");
|
||||
pthread_mutex_unlock(philo->print_lock);
|
||||
while (!dead_loop(philo))
|
||||
{
|
||||
ft_start_eating(philo);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/04 11:42:37 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/18 20:00:09 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/18 21:18:10 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,6 +17,8 @@ t_error ft_parsing_args(t_i32 argc, t_str *argv, t_philo *philo)
|
|||
t_usize tmp;
|
||||
|
||||
tmp = 0;
|
||||
philo->eating = 0;
|
||||
philo->eating_count = 0;
|
||||
ft_atou(argv[1], &tmp);
|
||||
if (tmp == 0)
|
||||
return (ERROR);
|
||||
|
|
@ -66,8 +68,6 @@ t_error ft_init_philo(t_i32 argc, t_str *argv, t_program *prog, t_mutex *forks)
|
|||
while (i < ft_atou_return(argv[1]))
|
||||
{
|
||||
prog->philos[i].id = i + 1;
|
||||
prog->philos[i].eating = 0;
|
||||
prog->philos[i].eating_count = 0;
|
||||
ft_parsing_args(argc, argv, &prog->philos[i]);
|
||||
prog->philos[i].start_time = ft_time();
|
||||
prog->philos[i].t_last_eat = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/11 11:42:31 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/18 18:38:04 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/18 21:18:49 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -83,9 +83,6 @@ void *ft_watch_dogs(void *ptr)
|
|||
if (philo == NULL)
|
||||
return (NULL);
|
||||
i = philo[0].nb_philo;
|
||||
pthread_mutex_lock(philo->print_lock);
|
||||
printf("\n\nEntre dans ft_watch_dogs\n\n");
|
||||
pthread_mutex_unlock(philo->print_lock);
|
||||
while (true)
|
||||
{
|
||||
if (check_eat(philo) == true)
|
||||
|
|
@ -93,9 +90,6 @@ void *ft_watch_dogs(void *ptr)
|
|||
if (check_dead(philo) == true)
|
||||
break ;
|
||||
}
|
||||
pthread_mutex_lock(philo->print_lock);
|
||||
printf("\n\nSortie de ft_watch_dogs\n\n");
|
||||
pthread_mutex_unlock(philo->print_lock);
|
||||
while (i-- != 0)
|
||||
{
|
||||
pthread_mutex_lock(philo[i].dead_lock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue