Skip to content

Commit

Permalink
add single-philo-case, test, add missing fct descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Schenk committed Oct 11, 2024
1 parent d77036f commit 8e7e004
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 5,326 deletions.
13 changes: 7 additions & 6 deletions philo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/03 14:29:17 by aschenk #+# #+# #
# Updated: 2024/10/11 19:43:22 by aschenk ### ########.fr #
# Updated: 2024/10/11 22:16:06 by aschenk ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -25,11 +25,12 @@ SRCS_DIR := src
SRCS_FILES := main.c \
1_check_args.c \
2_init_philos.c \
3_init_sim.c \
4_eat.c \
5_eat_sleep_think.c \
6_monitor.c \
7_run_sim.c \
2_init_sim.c \
3_eat.c \
3_eat_sleep_think.c \
4_monitor.c \
5_run_sim_utils.c \
5_run_sim.c \
utils/0_libft.c \
utils/1_print_action.c \
utils/1_print_error.c \
Expand Down
3 changes: 2 additions & 1 deletion philo/include/philo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/14 19:21:56 by aschenk #+# #+# */
/* Updated: 2024/10/11 19:52:51 by aschenk ### ########.fr */
/* Updated: 2024/10/11 22:11:17 by aschenk ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -81,6 +81,7 @@ the risk of starvation among others while still prioritizing their own needs.
// 1_check_args.c

int check_args(int argc, char **argv);
int simulate_single_philo(t_sim *sim);

// 2_init_philos.c

Expand Down
11 changes: 7 additions & 4 deletions philo/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 17:19:12 by aschenk #+# #+# */
/* Updated: 2024/10/11 12:25:02 by aschenk ### ########.fr */
/* Updated: 2024/10/11 22:26:12 by aschenk ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -75,12 +75,13 @@ Structure representing a philosopher in the dining philosophers problem:
- sim: A pointer to the simulation structure, allowing access
to shared data.
- id: The philosopher's identifier.
- thread_id: The identifier for the philosopher's thread.
- odd: A flag indicating if a philo's ID is odd or not.
- thread_id: The identifier for the philosopher's thread.
- meals_eaten: Counter for the number of meals the philosopher has eaten.
- done_eating: Indicates whether the philosopher has finished eating.
- is_alive: A flag indicating whether the philosopher is still alive.
- t_last_meal: Timestamp of the philosopher's last meal in milliseconds.
- mtx_last_meal: Mutex for synchronizing access to `t_last_meal`.
- mtx_last_meal_init: Flag checking if `mtx_last_meal` has been initialized.
- timestamp_death: Timestamp in milliseconds for when the philosopher dies.
- left_fork: A pointer to the philosopher's left fork.
- right_fork: A pointer to the philosopher's right fork.
*/
Expand Down Expand Up @@ -119,6 +120,8 @@ Structure representing the overall simulation state:
- t_start_sim: Timestamp in milliseconds for when the simulation started.
- forks: Array of forks available for the philosophers.
- philos: Array of philosophers participating in the simulation.
- monitor: Thread handle for the monitoring thread that observes the
state of the simulation.
- mtx_print: Mutex for synchronizing output to the console (printing).
- mtx_print_init: Flag checking if 'print' mutex has been initialized.
- mtx_full_philos: Mutex for checking / increasing 'full_philos'.
Expand Down
Loading

0 comments on commit 8e7e004

Please sign in to comment.