/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 11:10:17 by ljiriste #+# #+# */
-/* Updated: 2024/03/26 09:13:38 by ljiriste ### ########.fr */
+/* Updated: 2024/03/26 09:55:46 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
# include <pthread.h>
# include <sys/time.h>
+// The .start member holds the result of gettimeofday
+// Every other member that holds time info counts
+// microseconds from that point (in other structures also)
typedef struct s_settings
{
int end;
int should_check_hunger;
- size_t philo_count;
- suseconds_t time_to_die;
- suseconds_t time_to_eat;
- suseconds_t time_to_sleep;
- suseconds_t start;
unsigned int min_eat_num;
+ useconds_t time_to_die;
+ useconds_t time_to_eat;
+ useconds_t time_to_sleep;
+ size_t philo_count;
+ struct timeval start;
pthread_mutex_t terminal_lock;
pthread_mutex_t end_lock;
} t_settings;
{
int num_eaten;
size_t id;
- suseconds_t last_eaten;
+ useconds_t last_eaten;
t_settings *settings;
pthread_mutex_t *forks[2];
pthread_mutex_t philo_lock;