almost
This commit is contained in:
parent
c99ec1221d
commit
df7c2f7bf3
@ -6,13 +6,13 @@
|
||||
# By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / #
|
||||
# (| | )|_| |_| |> < #
|
||||
# Created: 2021/08/19 15:20:20 by djonker /'\_ _/`\__|\__,_/_/\_\ #
|
||||
# Updated: 2023/05/20 08:42:21 by djonker \___)=(___/ #
|
||||
# Updated: 2023/05/20 09:36:06 by djonker \___)=(___/ #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME =philo
|
||||
CC =gcc
|
||||
CFLAGS =-Wall -Werror -Wextra -g -fsanitize=thread
|
||||
CFLAGS =-Wall -Werror -Wextra# -g -fsanitize=thread
|
||||
RM =rm -f
|
||||
SRC =src/philo.c\
|
||||
src/init.c\
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
|
||||
/* (| | )|_| |_| |> < */
|
||||
/* Created: 2023/03/11 06:42:31 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
|
||||
/* Updated: 2023/05/20 09:08:25 by djonker \___)=(___/ */
|
||||
/* Updated: 2023/05/20 09:47:03 by djonker \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -47,7 +47,7 @@ void *ft_cycle(void *pointer)
|
||||
|
||||
philo = pointer;
|
||||
if ((philo->id - 1) % 2)
|
||||
usleep(*philo->eattime * 900);
|
||||
usleep(*philo->eattime * 1000);
|
||||
pthread_mutex_lock(philo->drdead);
|
||||
while (*philo->dead == 0)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
|
||||
/* (| | )|_| |_| |> < */
|
||||
/* Created: 2023/03/15 02:01:41 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
|
||||
/* Updated: 2023/05/20 08:27:44 by djonker \___)=(___/ */
|
||||
/* Updated: 2023/05/20 10:04:39 by djonker \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -83,11 +83,18 @@ int ft_cleanup(t_strct *strct)
|
||||
void ft_aliveprint(t_philo *ps, char *str)
|
||||
{
|
||||
pthread_mutex_lock(ps->drdead);
|
||||
if (!*ps->dead)
|
||||
if (*ps->dead)
|
||||
{
|
||||
pthread_mutex_unlock(ps->drdead);
|
||||
return ;
|
||||
}
|
||||
pthread_mutex_unlock(ps->drdead);
|
||||
printf("%lld %d %s\n", ft_time() - *ps->strtt, ps->id, str);
|
||||
}
|
||||
else
|
||||
pthread_mutex_unlock(ps->drdead);
|
||||
}
|
||||
|
||||
|
||||
/*• Test 1 800 200 200. The philosopher should not eat and should die.*/
|
||||
/*• Test 5 800 200 200. No philosopher should die.*/
|
||||
/*• Test 5 800 200 200 7. No philosopher should die and the simulation should stop when every philosopher has eaten at least 7 times.*/
|
||||
/*• Test 4 410 200 200. No philosopher should die.*/
|
||||
/*• Test 4 310 200 100. One philosopher should die.*/
|
||||
|
Loading…
Reference in New Issue
Block a user