NetApp Interview Question
Software Engineer / DevelopersIf we can build a resource allocation graph, then we can figure out the root cause of the deadlock. If there is a lower priority thread, then we can kill that first. But, I am not sure how this graph can be constructed - maybe the answer lies in the implementation of race detection tools.
I am not sure in how much detail RAGs should be explained.
Its not a simple thing to do but if you like to do that, you need to break the deadlock in such a way that there is least number of threads are effected or killed. you need to find all the resource taken by each thread and which thread is waiting on which resource and which thread has locked which resource. Once this cycle of dependency is identified, then you can break the chain by forcing one of the thread to release its resource and allocating that resource to a thread which can start working on it and then releases it later.
- Anonymous December 12, 2010in the worse case, you need to kill all the threads.