aboutsummaryrefslogtreecommitdiff
path: root/philo/include/philo.h
diff options
context:
space:
mode:
Diffstat (limited to 'philo/include/philo.h')
-rw-r--r--philo/include/philo.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/philo/include/philo.h b/philo/include/philo.h
index 1ec9c3d..cfc832e 100644
--- a/philo/include/philo.h
+++ b/philo/include/philo.h
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/17 10:23:19 by dkaiser #+# #+# */
-/* Updated: 2025/01/17 12:01:01 by dkaiser ### ########.fr */
+/* Updated: 2025/01/18 11:20:26 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,6 +21,13 @@
# include "ft_utils.h"
# define ERR_USAGE "Usage: <nbr_of_philos> <ttd> <tte> <tts> [times_must_eat]"
+# define ERR_MALLOC "Memory allocation failed"
+
+typedef struct s_fork
+{
+ int available;
+ pthread_mutex_t mutex;
+} t_fork;
typedef struct s_phdata
{
@@ -29,6 +36,17 @@ typedef struct s_phdata
int time_to_eat;
int time_to_sleep;
int times_must_eat;
+ int simulation_running;
+ t_fork *forks;
} t_phdata;
+typedef struct s_philo
+{
+ int id;
+ int times_eaten;
+ int is_alive;
+ pthread_t thread;
+ t_phdata *data;
+} t_philo;
+
#endif