- #1
twoski
- 181
- 2
Homework Statement
Here is the relevant info from the assignment handout:
http://pastebin.com/nfXcF88u
The Attempt at a Solution
I have written the code, however i do not see how deadlocks can even be possible with this assignment. Since there is a monitor thread which automatically frees resources after their usage time is ended, there is no way a deadlock could occur. I thought one of the conditions of deadlock was that a thread would not give up the resource it has until it is able to access the resource it wants. In this assignment, the monitor will force threads to release resources so even if there exists a cycle, it will be broken by the monitor thread very quickly.
It seems like the Banker's Algorithm would be overkill for this assignment. Can someone explain how exactly a deadlock would be possible?
Would it not be the most efficient to just let threads access the resources they need (unless of course there are no instances of a needed resource) until they are all done?
Last edited by a moderator: