Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yabtaour
GitHub Repository: yabtaour/Philosophers-42
Path: blob/master/philo/ft_routine.c
882 views
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_routine.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: yabtaour <[email protected]> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/05/19 22:06:12 by yabtaour #+# #+# */
9
/* Updated: 2022/05/19 23:00:39 by yabtaour ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
#include "philosophers.h"
13
14
void *routine(void *ptr)
15
{
16
t_philo *philosopher;
17
18
philosopher = (t_philo *)ptr;
19
while (!(philosopher->data->is_dead)
20
&& (philosopher->eat != philosopher->data->must_eat))
21
{
22
ft_eat(philosopher);
23
ft_output(philosopher->data, philosopher->philo_id, "is sleeping");
24
ft_sleep(philosopher->data->time_to_sleep, philosopher->data);
25
ft_output(philosopher->data, philosopher->philo_id, "is thinking");
26
}
27
return (NULL);
28
}
29
30