mirror of
https://github.com/Hizenberg469/Dining_philosopher.git
synced 2026-04-19 18:02:25 +03:00
23 lines
525 B
C
23 lines
525 B
C
#ifndef __DIN_PH_H__
|
|
#define __DIN_PH_H__
|
|
|
|
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct phil_ {
|
|
|
|
int phil_id;
|
|
pthread_t thread_handle;
|
|
int eat_count;
|
|
} phil_t;
|
|
|
|
typedef struct spoon_ {
|
|
|
|
int spoon_id;
|
|
bool is_used; /* bool to indicate if the spoon is being used or not */
|
|
phil_t* phil; /* If used, then which philosopher is using it */
|
|
pthread_mutex_t mutex; /* For Mutual Exclusion */
|
|
pthread_cond_t cv; /* For thread Co-ordination competing for this Resource */
|
|
} spoon_t;
|
|
|
|
#endif /* __DIN_PH_H__ */ |