diff options
| author | Dominik Kaiser | 2025-01-28 13:56:07 +0100 |
|---|---|---|
| committer | Dominik Kaiser | 2025-01-28 13:56:07 +0100 |
| commit | c33bbb4f66dbaca2f02b6f32c2d6bdb84be5f115 (patch) | |
| tree | a33a18e211b4fcae9e6d6dd8257ac56a5ae603f9 /philo/include/philo.h | |
| parent | ec7a989cf45440e41d43e7fa2d2ce660fa499933 (diff) | |
| download | Philosophers-c33bbb4f66dbaca2f02b6f32c2d6bdb84be5f115.tar.gz Philosophers-c33bbb4f66dbaca2f02b6f32c2d6bdb84be5f115.zip | |
Protect simulation_running with mutex
Diffstat (limited to 'philo/include/philo.h')
| -rw-r--r-- | philo/include/philo.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/philo/include/philo.h b/philo/include/philo.h index 07e4e96..ef5565e 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/28 13:16:12 by dkaiser ### ########.fr */ +/* Updated: 2025/01/28 13:34:48 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,6 +38,7 @@ typedef struct s_phdata int philos_must_eat; pthread_mutex_t pme_mutex; int simulation_running; + pthread_mutex_t sr_mutex; t_fork *forks; } t_phdata; @@ -57,6 +58,9 @@ int run_simulation(int nbr_of_philos, t_philo *philos, int philo_die(t_philo *philo); void philo_eat(t_philo *philo); +int is_simulation_running(t_phdata *data); +void stop_simulation(t_phdata *data); + /* ** Prints error message and returns EXIT_FAILURE */ @@ -73,8 +77,8 @@ int ft_atoi(const char *str); int ft_cur_time_in_ms(void); /* -** Prints "timestamp_in_ms id str" +** Prints "timestamp_in_ms philo->id str" */ -void ft_log(int id, const char *str); +void ft_log(t_philo *philo, const char *str); #endif |
