This commit is contained in:
Danny Jonker 2023-05-24 00:44:28 +02:00
parent 4c054fcdf0
commit 8b78ddb705
4 changed files with 13 additions and 14 deletions

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* .--. _ */ /* .--. _ */
/* init.c :+: :+: :+: */ /* init.c |o_o || | */
/* |:_/ || |_ _ ___ __ */ /* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */ /* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */ /* (| | )|_| |_| |> < */
/* Created: 2023/03/15 02:00:19 by houtworm /'\_ _/`\__|\__,_/_/\_\ */ /* Created: 2023/03/15 02:00:19 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/22 07:35:35 by houtworm ### ########.fr */ /* Updated: 2023/05/24 00:23:31 by djonker \___)=(___/ */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */ /* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */ /* (| | )|_| |_| |> < */
/* Created: 2023/03/11 06:42:31 by houtworm /'\_ _/`\__|\__,_/_/\_\ */ /* Created: 2023/03/11 06:42:31 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/23 04:03:02 by houtworm \___)=(___/ */ /* Updated: 2023/05/24 00:29:03 by djonker \___)=(___/ */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -63,9 +63,9 @@ int ft_startcycle(t_strct *st)
i = 0; i = 0;
st->strtt = ft_time(); st->strtt = ft_time();
st->alive = 1;
while (i < st->philos) while (i < st->philos)
{ {
st->alive = 1;
st->pid[i] = fork(); st->pid[i] = fork();
if (st->pid[i] == 0) if (st->pid[i] == 0)
{ {
@ -102,7 +102,6 @@ int main(int argc, char **argv)
} }
i = ft_initstructandmutex(strct, 0); i = ft_initstructandmutex(strct, 0);
ft_startcycle(strct); ft_startcycle(strct);
usleep(1000);
strct->pid[501] = fork(); strct->pid[501] = fork();
if (strct->pid[501] == 0) if (strct->pid[501] == 0)
ft_waitingfordeath(strct); ft_waitingfordeath(strct);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* .--. _ */ /* .--. _ */
/* util.c :+: :+: :+: */ /* util.c |o_o || | */
/* |:_/ || |_ _ ___ __ */ /* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */ /* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */ /* (| | )|_| |_| |> < */
/* Created: 2023/03/15 02:01:41 by houtworm /'\_ _/`\__|\__,_/_/\_\ */ /* Created: 2023/03/15 02:01:41 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/22 07:36:43 by houtworm ### ########.fr */ /* Updated: 2023/05/24 00:23:12 by djonker \___)=(___/ */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* .--. _ */
/* watch.c |o_o || | */ /* watch.c |o_o || | */
/* +:+ +:+ +:+ */ /* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */ /* By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / */
/* +#+#+#+#+#+ +#+ */ /* (| | )|_| |_| |> < */
/* Created: 2023/05/22 07:34:59 by houtworm #+# #+# */ /* Created: 2023/05/24 00:23:22 by djonker /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/23 04:06:37 by houtworm \___)=(___/ */ /* Updated: 2023/05/24 00:28:28 by djonker \___)=(___/ */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ int ft_releasetheminds(t_strct *strct, int m)
i = 0; i = 0;
if (m) if (m)
{ {
while (i < (strct->philos * 2) - 1) while (i < (strct->philos * 2))
{ {
sem_post(strct->hold); sem_post(strct->hold);
i++; i++;