2. How to solve unbounded-buffer producer-consumer wiht locks. producer while it's true acquire lock produce unity counter + + Condition call to lock release the lock consumer While it's true acquire lock while the counter is equal to 0 call waiting lock condition end consume the next unit counter - lock release
3.
4. How to detect and eliminate deadlocks in the dining philosophers problem Check If the left fork is available, take it If the left fork is available, take it Eat Put the left fork down Put the right down If philosopher[ i ] is hungry and left and right philosopher are thinking Then take the fork
5. check{ var (i, temp) when i is less than the number of pholosophers { If the philosopher i is return true If the left and right philosophers have a fork temp++ i++ } If temp = number of philosophers return true }
6. Examle When you acquire resources (such as the Fork object) in ascending order, circular wait is impossible: for a circular wait to occur, some thread must be holding a higher numbered resource waiting for a lower numbered resource, but that is forbidden. We can use resource enumeration in the Dining Philosophers problem to eliminate deadlock.