This commit is contained in:
djonker 2023-05-23 04:05:44 +02:00
parent 50dd3af824
commit 619ebba469
2 changed files with 10 additions and 8 deletions

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* .--. _ */
/* philo.c :+: :+: :+: */
/* philo.c |o_o || | */
/* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */
/* Created: 2023/03/11 06:42:31 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/05/22 08:10:48 by houtworm ### ########.fr */
/* Updated: 2023/05/23 04:03:02 by houtworm \___)=(___/ */
/* */
/* ************************************************************************** */
@ -65,8 +65,8 @@ int ft_startcycle(t_strct *st)
st->strtt = ft_time();
while (i < st->philos)
{
st->pid[i] = fork();
st->alive = 1;
st->pid[i] = fork();
if (st->pid[i] == 0)
{
st->philo[i].alive = &st->alive;
@ -102,6 +102,7 @@ int main(int argc, char **argv)
}
i = ft_initstructandmutex(strct, 0);
ft_startcycle(strct);
usleep(1000);
strct->pid[501] = fork();
if (strct->pid[501] == 0)
ft_waitingfordeath(strct);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* watch.c :+: :+: :+: */
/* watch.c |o_o || | */
/* +:+ +:+ +:+ */
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/22 07:34:59 by houtworm #+# #+# */
/* Updated: 2023/05/23 03:07:31 by houtworm ### ########.fr */
/* Updated: 2023/05/23 04:04:00 by houtworm \___)=(___/ */
/* */
/* ************************************************************************** */
@ -19,8 +19,8 @@ int ft_releasetheminds(t_strct *strct, int m)
i = 0;
if (m)
{
strct->strtt = ft_time();
while (i < strct->philos)
/*strct->strtt = ft_time();*/
while (i < (strct->philos * 2) - 1)
{
sem_post(strct->hold);
i++;
@ -76,7 +76,8 @@ void *ft_alive(void *pointer)
t_philo *philo;
philo = pointer;
usleep(*philo->dietime);
/*usleep(*philo->dietime);*/
sem_wait(philo->hold);
while (ft_time() - philo->lastfood < *philo->dietime)
usleep(500);
sem_post(philo->dead);