-
Notifications
You must be signed in to change notification settings - Fork 0
/
outils.c
45 lines (38 loc) · 1.41 KB
/
outils.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
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* outils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amaach <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/05 11:54:42 by amaach #+# #+# */
/* Updated: 2021/11/05 12:02:25 by amaach ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
unsigned long long ft_gettime(void)
{
struct timeval time;
unsigned long long time_in_mill;
gettimeofday(&time, NULL);
time_in_mill = (time.tv_sec) * 1000 + (time.tv_usec) / 1000;
return (time_in_mill);
}
t_infos *statlist(void)
{
static t_infos ret;
return (&ret);
}
void my_sleep(unsigned long long i)
{
unsigned long long current_time;
unsigned long long time_beggin;
time_beggin = ft_gettime();
while (1)
{
usleep(100);
current_time = ft_gettime();
if (current_time >= time_beggin + i)
break ;
}
}