Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yabtaour
GitHub Repository: yabtaour/Philosophers-42
Path: blob/master/philo_bonus/ft_output_bonus.c
882 views
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_output_bonus.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: yabtaour <[email protected]> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/05/23 00:06:52 by yabtaour #+# #+# */
9
/* Updated: 2022/05/23 00:06:54 by yabtaour ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
#include "philosophers_bonus.h"
13
14
void ft_output(t_data *data, int philo_id, char *str)
15
{
16
sem_wait(data->output);
17
if (!(data->is_dead))
18
{
19
printf("[%lld] ", ft_timestamp() - data->birth);
20
printf("Philosopher %d %s\n", philo_id, str);
21
}
22
sem_post(data->output);
23
}
24
25