aboutsummaryrefslogtreecommitdiff
path: root/philo/include
diff options
context:
space:
mode:
authorDominik Kaiser2025-01-18 11:21:35 +0100
committerDominik Kaiser2025-01-18 11:21:35 +0100
commitf6e38aa3145682265c84487fb01ace835c8f17d0 (patch)
tree3314ca9ad8177cedfc25d1f7bee754aa25bc74e2 /philo/include
parent0d910cd1b5e3b40ef91c4ee5334305530015a181 (diff)
downloadPhilosophers-f6e38aa3145682265c84487fb01ace835c8f17d0.tar.gz
Philosophers-f6e38aa3145682265c84487fb01ace835c8f17d0.zip
Add structs and init
Diffstat (limited to 'philo/include')
-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