philosophers/time.c
2023-12-12 17:37:16 +01:00

30 lines
1.2 KiB
C
Executable File

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* time.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/17 15:31:00 by fgras-ca #+# #+# */
/* Updated: 2023/10/17 16:20:32 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
long initialize_start_time(void)
{
struct timeval now;
gettimeofday(&now, NULL);
return ((now.tv_sec * 1000) + (now.tv_usec / 1000));
}
long get_time(long start_time)
{
struct timeval now;
gettimeofday(&now, NULL);
return (((now.tv_sec * 1000) + (now.tv_usec / 1000)) - start_time);
}