From e3bac2aeba6c2a40e4705133974574ce1195b258 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Fri, 30 Sep 2022 01:20:28 -0500 Subject: [PATCH] Fixed print statement in functions --- DiningPhilosophers.c | 8 +++++--- DiningPhilosophers.out | Bin 16720 -> 16720 bytes output.log | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/DiningPhilosophers.c b/DiningPhilosophers.c index 06f96d6..787ea1d 100644 --- a/DiningPhilosophers.c +++ b/DiningPhilosophers.c @@ -90,7 +90,9 @@ void Down() // void Eat(PhilosopherData* philosopherSelected) { - printf("Eat() was called...\n"); + printf("Philosopher %d is eating...\n", philosopherSelected->position); + philosopherSelected->state = EATING; + ++philosopherSelected->eatingCount; } // Takes in char* and converts into a number @@ -156,7 +158,7 @@ void PhilosopherListInit(PhilosopherData PhilosopherList[], int philosopherTotal void PutForks(PhilosopherData* philosopherSelected) { - printf("PutForks() was called...\n"); + printf("Philosopher %d is putting forks down...\n", philosopherSelected->position); // Down(&mutex); /*enter critical region*/ // philosopherState[selectedPhilosopher] = THINKING; /*record fact that philosopher i is hungry*/ // Test(selectedPhilosopher, numPhilosophers); @@ -168,7 +170,7 @@ void PutForks(PhilosopherData* philosopherSelected) // Takes in a number for a selected philosopher, from 0 to N-1 void TakeForks(PhilosopherData* philosopherSelected) { - printf("TakeForks() was called...\n"); + printf("Philosopher %d is taking forks...\n", philosopherSelected->position); sem_wait(&philosopherSelected->semaphore); // Down(&mutex); /*enter critical region*/ // PhilosopherList.state = HUNGRY; /*philosopher has finished eating*/ diff --git a/DiningPhilosophers.out b/DiningPhilosophers.out index e0a0e766946501482d133a7ed7d0046112640acd..bab73814aabb0e6a9674b146509aca45fad04725 100755 GIT binary patch delta 1124 zcmZvcZAep57{~9q({wgP(i)4NtH`HNem=Vp_R&Q!YzJ2xJx!sdT{ji{;!?OIi4F0eT7}VO=7!j z!Ow33{dUv3!?bQ6n=Ju*V0)^=wBj&&*x#EwJkxzS&TJoh&W6s8Y*1=Oam*OYW6h2Z zt|OnYgIx)_ptyhy1@nK}YOz64PzcF@`k?5r0S~DM#o2C5&Dz*mCq4^0PsnLdsSXh{ z7*%N`7wT2XBoGEwhxw^Bm{L6;7PuC2mI$~D{w}k_82^f8V*La>)UgFD%x35axm%Dz zH?LCKIsW#if8^R3vwgMGrSw|g(Yt*BzlzU{=h@L0%b3SOY}9riv%&LN*7JqX7o|Df~<))9-8 zhGX4^JcgV`79v-WSCPk;D7}xoi+qWkL4HB<%an5X3rPD-serT~jmUoF1!UX4f0wwo6K=WAW1P{gP~G&Kms?4;{!P**9X~22C^t#O45)pzYs}H zL6NO{c*D#j!a%ZxIa?YEy!ElB_?%bU2gzp)-ybpoIOuf&J|Aq3* QRC$k98rmZcWcKra0k#ZgEC2ui delta 1015 zcmZ{je@IhN6vyv<)7%rCKjwUz=H|qlsayWcr1=9~&MeYULa=BwF@J!XN-*JsI{6lErru~$iU2Ub?Puuo9KiV|xl|A1Op}HWp z$z~La9`xHxORc6Q+rvpC*nHa*cGnC~Ld+QV{bUSsl`*s%*Gpj#OpXm`QWt)>O3LOYJPvd9<=EV1hKdJ=9WdG&Q$s}5Gw{-qUIDoXyTz?dfUMAi&r!+1&0kWCM;XO*aG;l5CYt{4`)M(YASJ10n?JaUx9bOL{@+u6V_cc7lHxIMgFpir8 z|FDn@VgCOI`|)5P>T#3m3XpBjw&EoBtK^g6W zBeB`sxCZXU>gjrzjUA+V7>E;SGmOL;c%vXyCnOGNd_-VbfHPX_1R25>zQmgxhm3dw z9T98d)im(E%Bd!zD6NZl%aW-IdJ{^i7JL%Z_@L#oTCpf`x146efYHD=FIR7d55{cz d3Sv{#keBN1zUo&kPfg;hL!EW2#op8&?ic8vMf3mw diff --git a/output.log b/output.log index 62264e3..4306451 100644 --- a/output.log +++ b/output.log @@ -1,20 +1,20 @@ Philosopher 0 is thinking... -TakeForks() was called... -Eat() was called... -PutForks() was called... +Philosopher 0 is taking forks... +Philosopher 0 is eating... +Philosopher 0 is putting forks down... Philosopher 1 is thinking... -TakeForks() was called... -Eat() was called... -PutForks() was called... +Philosopher 1 is taking forks... +Philosopher 1 is eating... +Philosopher 1 is putting forks down... Philosopher 2 is thinking... -TakeForks() was called... -Eat() was called... -PutForks() was called... +Philosopher 2 is taking forks... +Philosopher 2 is eating... +Philosopher 2 is putting forks down... Philosopher 3 is thinking... -TakeForks() was called... -Eat() was called... -PutForks() was called... +Philosopher 3 is taking forks... +Philosopher 3 is eating... +Philosopher 3 is putting forks down... Philosopher 4 is thinking... -TakeForks() was called... -Eat() was called... -PutForks() was called... +Philosopher 4 is taking forks... +Philosopher 4 is eating... +Philosopher 4 is putting forks down...