tgrekov-philosophers
HIVE philosophers July 2024
Loading...
Searching...
No Matches
sim_end.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* check_end.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/07/27 13:41:24 by tgrekov #+# #+# */
9/* Updated: 2024/07/28 12:56:49 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include "philo.h"
21
28int check_end(t_global *global)
29{
30 int end;
31
32 pthread_mutex_lock(&global->end_mutex);
33 end = global->end;
34 pthread_mutex_unlock(&global->end_mutex);
35 return (end);
36}
37
38int set_end(t_global *global)
39{
40 int was_set;
41
42 pthread_mutex_lock(&global->end_mutex);
43 was_set = global->end;
44 global->end = 1;
45 pthread_mutex_unlock(&global->end_mutex);
46 return (was_set);
47}
int check_end(t_global *global)
Check if the simulation has ended.
Definition sim_end.c:28