init mutex broken
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#ifndef PHILO_PROTO_H
|
||||
# define PHILO_PROTO_H
|
||||
|
||||
// t_mtx mutex;
|
||||
|
||||
// init.c
|
||||
t_philo *init(int ac, char **av, pthread_t **id);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ t_philo *init(int ac, char **av, pthread_t **id)
|
||||
{
|
||||
t_philo *philo;
|
||||
t_params *params;
|
||||
t_mtx msg_mtx;
|
||||
t_mtx *m_print;
|
||||
|
||||
params = init_params(ac, av);
|
||||
if (params == NULL)
|
||||
@@ -70,8 +70,10 @@ t_philo *init(int ac, char **av, pthread_t **id)
|
||||
*id = malloc(sizeof(int) * params->n_phi);
|
||||
if (*id == NULL)
|
||||
return (NULL);
|
||||
pthread_mutex_init(&msg_mtx, NULL);
|
||||
philo = init_chain_philo(params, &msg_mtx);
|
||||
m_print = NULL;
|
||||
if (pthread_mutex_init(m_print, NULL) != 0)
|
||||
return (NULL);
|
||||
philo = init_chain_philo(params, m_print);
|
||||
if (philo == NULL)
|
||||
return (NULL);
|
||||
return (philo);
|
||||
|
||||
@@ -24,7 +24,6 @@ int main(int ac, char **av)
|
||||
if (philo == NULL)
|
||||
return (0);
|
||||
n = philo->params->n_phi;
|
||||
// pthread_mutex_init(&mutex, NULL);
|
||||
create_threads(philo, id, n);
|
||||
i = 0;
|
||||
while (i < n)
|
||||
|
||||
Reference in New Issue
Block a user