Linux下实现哲学家就餐问题

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define NUM_THREADS_P 5
#define CHAIR_NUM 4
#define CHOP_NUM  5

int chairflg[CHAIR_NUM][2],dining_num = 0;
sem_t chair,chopstics[CHOP_NUM],mutex,mutex1,print_mutex;
pthread_t threads_p[NUM_THREADS_P];

void *philosopher_thread(void *args);

int main(void)
{
    int i;
    
    sem_init(&chair, 0, CHAIR_NUM);
    for(i=0; i

你可能感兴趣的:(Linux)