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

Async interrupt should not work #21

Open
msoos opened this issue Mar 26, 2015 · 0 comments
Open

Async interrupt should not work #21

msoos opened this issue Mar 26, 2015 · 0 comments

Comments

@msoos
Copy link

msoos commented Mar 26, 2015

The Solver::interrupt(){ asynch_interrupt = true; } with bool asynch_interrupt; should not really work -- it's not clear that asynch_interrupt can be changed from another thread and the compiler is completely at liberty to optimize out the check (as I suspect it does). It should have lock/atomic/etc. primitives around it so the compiler is aware that it can be changed from elsewhere. Also note that using volatile does not fix this issue -- it does not signal the system that another thread might change the value and so it does not force a memory sync between the threads. A memory barrier is needed before every access to it from any thread, i.e. one after the change in interrupt() and one everywhere where the value of asynch_interrupt is checked.

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

No branches or pull requests

1 participant