Commit d0547dd5 authored by Son Pham's avatar Son Pham

Lab 7, Problem 1 Completed

parent 7792d793
......@@ -3,7 +3,7 @@
# Prof: Luiz Felipe Perrone
# answers.txt
[1.1] About three seconds into the execution, I see five left chopsticks picked up by the philosophers and the program entered deadlock.
[1.1] About three seconds into the execution, The program seems to stop functioning entirely with a bunch of philosophers getting hungry.
[1.2] Deadlock could happen because current execution of the program satisfy all conditions for deadlock:
......@@ -11,5 +11,3 @@
- Hold and wait: The philosopher can hold the left chopstick and request the right chopstick which can be hold by another philosopher
- No premption: The philosopher won't release his favorite left chopstick until he get the right chopstick and enter critical section.
- Circular wait: Philosopher tries to request the right chopsticks in circle.
There were no avoidance mechanism, so deadlock occured.
......@@ -63,10 +63,7 @@ void* philosopher(void* param) {
// Eating seciont
printf("Philosopher %d is hungry\n", id);
printf("Philosopher %d picked up the left chopstick\n",id);
printf("Philosopher %d picked up the right chopstick\n",id);
// -- Critical section
printf("Philosopher %d is ready to eat\n", id);
// Eat for some amount of time
......@@ -78,10 +75,8 @@ void* philosopher(void* param) {
// Releasing the chopsticls
printf("Philosopher %d released up the left chopstick\n",id);
printf("Philosopher %d released up the right chopstick\n",id);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment