1
0

」 feat: added timing calc and parsing

This commit is contained in:
2024-07-09 13:18:59 +02:00
parent ba70da4a67
commit 4c6644e1b2
9 changed files with 172 additions and 11 deletions

View File

@ -6,26 +6,44 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/07 15:11:02 by adjoly #+# #+# */
/* Updated: 2024/07/07 16:18:23 by adjoly ### ########.fr */
/* Updated: 2024/07/09 12:04:14 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PHILO_H
# define PHILO_H
# include <stdio.h>
# include <pthread.h>
# include <stdint.h>
# include <stdbool.h>
# include <sys/time.h>
typedef enum s_philo_state
typedef enum s_pstate
{
DIED = -1,
EAT,
THINK,
SLEEP,
FORK_TAKEN
} t_philo_state;
} t_pstate;
void log_philo(uint32_t timestamp, uint16_t philo, t_philo_state type);
typedef struct s_pdata
{
uint32_t die_time;
uint32_t sleep_time;
uint32_t eat_time;
uint16_t philo_nbr;
uint8_t meal_nbr;
bool error;
} t_pdata;
void log_philo(uint32_t timestamp, uint16_t philo, t_pstate type);
t_pdata philo_parse(char **argv, int ac);
uint16_t get_time_in_ms(struct timeval t0, struct timeval t1);
/**
* For debug purpose to be REMOVED
*/
void print_philo_data(t_pdata data);
#endif

18
philo/include/utils.h Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/08 17:46:19 by adjoly #+# #+# */
/* Updated: 2024/07/08 17:46:50 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef UTILS_H
# define UTILS_H
long long ft_atoll(const char *nptr);
#endif