Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock detection #27

Open
rplzzz opened this issue Nov 19, 2018 · 2 comments
Open

Deadlock detection #27

rplzzz opened this issue Nov 19, 2018 · 2 comments

Comments

@rplzzz
Copy link
Contributor

rplzzz commented Nov 19, 2018

I have an idea for detecting deadlock in a setup. What if we kept a dictionary of all of the components, with the associated values being status indicators. On initialization, each component would set its status to ready. On exit it would set it to finished. In the meantime, whenever it enters the blocking section of fetch, it would set its status to waiting, and on release it would set the status back to ready. (Needless to say, all this status updating would be handled in the component base class methods.) Then we could have a monitor thread that would periodically (every five minutes or so) wake up and check the table. If there isn't at least one ready thread, then the system has deadlocked, and we need to abort.

A more sophisticated version of this scheme would be to store the capability being waited on along with the wait status. The monitor could then use this information to build the graph of dependencies among the waiting threads. If there is a cycle in the graph, then deadlock has occurred, even if there are still ready threads, and again, we need to abort the run.

@calebbraun
Copy link
Contributor

With the first idea, how could we avoid the possibility of having the monitor thread reporting false deadlock? It could read the status of all threads as waiting if it accessed the dictionary in the middle of another thread updating it.

Overall the second idea seems cleaner to me anyway, and not too difficult to implement.

@rplzzz
Copy link
Contributor Author

rplzzz commented Nov 19, 2018

@calebbraun if all the threads end up in a waiting state at the same time, then none of them is ever going to emerge (assuming that we set the status only after we have decided to wait); however, I agree with the gist of your comment. I didn't think of the graph solution until I had already written the other stuff, and I was too lazy to delete the first paragraph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants