From 431dcb6aa63ce8f80b3bd3a9cf078cffa9d17130 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Mon, 3 Oct 2022 02:33:26 -0500 Subject: [PATCH] Removed commented code and test prints. --- DiningPhilosophers.c | 13 ------------- DiningPhilosophers.out | Bin 16808 -> 16808 bytes 2 files changed, 13 deletions(-) diff --git a/DiningPhilosophers.c b/DiningPhilosophers.c index ec8b3f6..9735572 100644 --- a/DiningPhilosophers.c +++ b/DiningPhilosophers.c @@ -61,7 +61,6 @@ bool AllPhilosophersFull(PhilosopherData PhilosopherList[], int numPhilosophers) // Philosopher enters critical section. void PhilosopherWait() { - printf("A thread was put into waiting...\n"); sem_wait(&semaphore); } @@ -107,10 +106,6 @@ void PhilosopherInit(int philosopherTotal) sem_init(&semaphore, 0, 1); while (!AllPhilosophersFull(PhilosopherList, philosopherTotal)) { - for (int i = 0; i < philosopherTotal; i++) - { - printf("Philosopher %d state: %d\n", PhilosopherList[i].position, PhilosopherList[i].state); - } AllowPhilosopher(); sleep(1); } @@ -129,7 +124,6 @@ void PhilosopherListInit(PhilosopherData PhilosopherList[], int philosopherTotal PhilosopherList[i].eatingCount = 0; PhilosopherList[i].state = THINKING; pthread_create(&PhilosopherList[i].thread, NULL, &Philosopher, &PhilosopherList[i]); - // pthread_join(&PhilosopherList[i].thread, NULL); } } @@ -154,12 +148,6 @@ bool PhilosopherCanEat(PhilosopherData PhilosopherList[], int selectedPosition, { if (PhilosopherList[selectedPosition].state != HUNGRY) return false; - // int leftPhilosopher = (selectedPosition + (philosopherTotal-1)) % philosopherTotal; - // int rightPhilosopher = (selectedPosition + 1) % philosopherTotal; - // if (PhilosopherList[leftPhilosopher].state == EATING) - // return false; - // if (PhilosopherList[rightPhilosopher].state == EATING) - // return false; for (int i = 0; i < philosopherTotal; i++) if (PhilosopherList[i].state == EATING) return false; @@ -177,5 +165,4 @@ void Think(PhilosopherData* philosopherSelected) void AllowPhilosopher() { sem_post(&semaphore); - printf("A thread was released...\n"); } diff --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