Fixed print statement in functions
This commit is contained in:
parent
86c7c0a3e5
commit
e3bac2aeba
@ -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*/
|
||||
|
Binary file not shown.
30
output.log
30
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...
|
||||
|
Loading…
Reference in New Issue
Block a user