|
|
@ -6,7 +6,7 @@ |
|
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
|
/* Created: 2022/05/16 14:04:06 by narnaud #+# #+# */ |
|
|
|
/* Updated: 2022/05/20 09:57:42 by narnaud ### ########.fr */ |
|
|
|
/* Updated: 2022/05/20 10:36:06 by narnaud ### ########.fr */ |
|
|
|
/* */ |
|
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
@ -30,7 +30,6 @@ t_table *parsing(char **argv) |
|
|
|
t_table *table; |
|
|
|
|
|
|
|
table = malloc(sizeof(t_table)); |
|
|
|
//ft_bzero(table, 0, sizeof(t_table));
|
|
|
|
table->param[PHILO_AMOUNT] = mini_atoi(argv[0]); |
|
|
|
table->param[DIE_TIME] = mini_atoi(argv[1]); |
|
|
|
table->param[EAT_DURATION] = mini_atoi(argv[2]); |
|
|
@ -41,18 +40,17 @@ t_table *parsing(char **argv) |
|
|
|
table->param[MEALS_AMOUNT] = 2147483647; |
|
|
|
table->time = gettime(); |
|
|
|
table->philos = malloc(sizeof(t_philo) * table->param[PHILO_AMOUNT]); |
|
|
|
//memset(table->philos, 0, sizeof(t_philo) * table->nb_of_philos);
|
|
|
|
return (table); |
|
|
|
} |
|
|
|
|
|
|
|
int gettime(void) |
|
|
|
{ |
|
|
|
static struct timeval starttime = {0,0}; |
|
|
|
static struct timeval starttime = {0, 0}; |
|
|
|
struct timeval actualtime; |
|
|
|
|
|
|
|
if(starttime.tv_sec == 0 && starttime.tv_usec == 0) |
|
|
|
if (starttime.tv_sec == 0 && starttime.tv_usec == 0) |
|
|
|
gettimeofday(&starttime, NULL); |
|
|
|
gettimeofday(&actualtime, NULL); |
|
|
|
return ((int)((actualtime.tv_sec * 1000 + actualtime.tv_usec / 1000)\ |
|
|
|
return ((int)((actualtime.tv_sec * 1000 + actualtime.tv_usec / 1000) |
|
|
|
- (starttime.tv_sec * 1000 + starttime.tv_usec / 1000))); |
|
|
|
} |
|
|
|