42 school project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5 KiB

3 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philosophers.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/24 15:44:06 by narnaud #+# #+# */
3 years ago
/* Updated: 2022/03/31 12:37:23 by narnaud ### ########.fr */
3 years ago
/* */
/* ************************************************************************** */
#ifndef PHILOSOPHERS_H
# define PHILOSOPHERS_H
# define CLOCK_ONE 500
# define CLOCK_TWO 1000
# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <pthread.h>
# include <sys/time.h>
3 years ago
enum e_params
3 years ago
{
3 years ago
PHILO_AMOUNT,
DIE_TIME,
EAT_DURATION,
SLEEP_DURATION,
MEALS_AMOUNT,
};
3 years ago
typedef struct s_philo
{
pthread_mutex_t *fork;
3 years ago
pthread_mutex_t *lock;
3 years ago
pthread_t *thd;
3 years ago
int eat_time;
3 years ago
int eat_amount;
int i;
} t_philo;
typedef struct s_room
{
3 years ago
int param[5];
3 years ago
t_philo **philos;
3 years ago
pthread_mutex_t *lock;
3 years ago
int running;
int i;
} t_room;
3 years ago
int waiter(t_room *room);
3 years ago
void *philos_life(void *r);
3 years ago
int room_clock();
3 years ago
#endif