-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphilo_utils.c
More file actions
31 lines (26 loc) · 1.18 KB
/
philo_utils.c
File metadata and controls
31 lines (26 loc) · 1.18 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philo_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jemartel <jemartel@student.42quebec> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/15 21:52:41 by jemartel #+# #+# */
/* Updated: 2022/02/15 21:53:27 by jemartel ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
unsigned int current_time(void)
{
struct timeval te;
gettimeofday(&te, NULL);
return ((te.tv_sec * 1000) + (te.tv_usec / 1000));
}
void sleep_time(int lenght)
{
const long time = current_time();
while (current_time() < time + lenght)
{
usleep(current_time() - time + lenght);
}
}