aboutsummaryrefslogtreecommitdiff
path: root/philo_one/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'philo_one/fork.c')
-rw-r--r--philo_one/fork.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/philo_one/fork.c b/philo_one/fork.c
index fd7ee90..ed1d642 100644
--- a/philo_one/fork.c
+++ b/philo_one/fork.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/09 23:46:40 by cacharle #+# #+# */
-/* Updated: 2020/02/14 21:18:02 by cacharle ### ########.fr */
+/* Updated: 2020/02/14 21:31:40 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -58,3 +58,10 @@ t_routine_arg *forks_dispatch(t_philo *philos, t_fork *forks, t_philo_args *args
}
return (routine_args);
}
+
+void fork_switch(t_fork *fork)
+{
+ pthread_mutex_lock(&fork->mutex);
+ fork->used = !fork->used;
+ pthread_mutex_unlock(&fork->mutex);
+}