Fixed print statement in functions
This commit is contained in:
parent
86c7c0a3e5
commit
e3bac2aeba
@ -90,7 +90,9 @@ void Down()
|
|||||||
//
|
//
|
||||||
void Eat(PhilosopherData* philosopherSelected)
|
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
|
// Takes in char* and converts into a number
|
||||||
@ -156,7 +158,7 @@ void PhilosopherListInit(PhilosopherData PhilosopherList[], int philosopherTotal
|
|||||||
|
|
||||||
void PutForks(PhilosopherData* philosopherSelected)
|
void PutForks(PhilosopherData* philosopherSelected)
|
||||||
{
|
{
|
||||||
printf("PutForks() was called...\n");
|
printf("Philosopher %d is putting forks down...\n", philosopherSelected->position);
|
||||||
// Down(&mutex); /*enter critical region*/
|
// Down(&mutex); /*enter critical region*/
|
||||||
// philosopherState[selectedPhilosopher] = THINKING; /*record fact that philosopher i is hungry*/
|
// philosopherState[selectedPhilosopher] = THINKING; /*record fact that philosopher i is hungry*/
|
||||||
// Test(selectedPhilosopher, numPhilosophers);
|
// Test(selectedPhilosopher, numPhilosophers);
|
||||||
@ -168,7 +170,7 @@ void PutForks(PhilosopherData* philosopherSelected)
|
|||||||
// Takes in a number for a selected philosopher, from 0 to N-1
|
// Takes in a number for a selected philosopher, from 0 to N-1
|
||||||
void TakeForks(PhilosopherData* philosopherSelected)
|
void TakeForks(PhilosopherData* philosopherSelected)
|
||||||
{
|
{
|
||||||
printf("TakeForks() was called...\n");
|
printf("Philosopher %d is taking forks...\n", philosopherSelected->position);
|
||||||
sem_wait(&philosopherSelected->semaphore);
|
sem_wait(&philosopherSelected->semaphore);
|
||||||
// Down(&mutex); /*enter critical region*/
|
// Down(&mutex); /*enter critical region*/
|
||||||
// PhilosopherList.state = HUNGRY; /*philosopher has finished eating*/
|
// 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...
|
Philosopher 0 is thinking...
|
||||||
TakeForks() was called...
|
Philosopher 0 is taking forks...
|
||||||
Eat() was called...
|
Philosopher 0 is eating...
|
||||||
PutForks() was called...
|
Philosopher 0 is putting forks down...
|
||||||
Philosopher 1 is thinking...
|
Philosopher 1 is thinking...
|
||||||
TakeForks() was called...
|
Philosopher 1 is taking forks...
|
||||||
Eat() was called...
|
Philosopher 1 is eating...
|
||||||
PutForks() was called...
|
Philosopher 1 is putting forks down...
|
||||||
Philosopher 2 is thinking...
|
Philosopher 2 is thinking...
|
||||||
TakeForks() was called...
|
Philosopher 2 is taking forks...
|
||||||
Eat() was called...
|
Philosopher 2 is eating...
|
||||||
PutForks() was called...
|
Philosopher 2 is putting forks down...
|
||||||
Philosopher 3 is thinking...
|
Philosopher 3 is thinking...
|
||||||
TakeForks() was called...
|
Philosopher 3 is taking forks...
|
||||||
Eat() was called...
|
Philosopher 3 is eating...
|
||||||
PutForks() was called...
|
Philosopher 3 is putting forks down...
|
||||||
Philosopher 4 is thinking...
|
Philosopher 4 is thinking...
|
||||||
TakeForks() was called...
|
Philosopher 4 is taking forks...
|
||||||
Eat() was called...
|
Philosopher 4 is eating...
|
||||||
PutForks() was called...
|
Philosopher 4 is putting forks down...
|
||||||
|
Loading…
Reference in New Issue
Block a user