-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
33 lines (29 loc) · 1.29 KB
/
utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttavares <ttavares@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/08 18:24:48 by ttavares #+# #+# */
/* Updated: 2023/05/26 11:59:55 by ttavares ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/philo.h"
long long time_snap(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
void printing(t_philo *philo, char *str)
{
pthread_mutex_lock(&philo->data->print);
if (!(philo->data->dead))
{
printf("%lld ", time_snap() - philo->data->time_start);
printf("%d ", philo->id);
printf("%s\n", str);
}
pthread_mutex_unlock(&philo->data->print);
}