32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: o_ :::::: ::: */
|
|
/* create_mutexes.c :+: / :+::+: :+: */
|
|
/* +:+ > +:++:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
|
/* +#+ +#+#+ +#++#+ +#+ \o/ */
|
|
/* Created: 2025/01/20 14:26:44 by whaffman #+#+# #+#+# #+# #+# | */
|
|
/* Updated: 2025/01/27 14:13:51 by whaffman ### ### ### ### / \ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "philo.h"
|
|
|
|
int create_mutexes(t_rules *rules)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
if (pthread_mutex_init(rules->finished_lock, NULL))
|
|
return (FAILURE);
|
|
if (pthread_mutex_init(rules->print_lock, NULL))
|
|
return (FAILURE);
|
|
while (i < rules->n_philos)
|
|
{
|
|
if (pthread_mutex_init(&rules->forks[i], NULL))
|
|
return (FAILURE);
|
|
i++;
|
|
}
|
|
return (SUCCESS);
|
|
}
|