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

Correctness for Condition Variables (Edge-triggered events) #2

Open
1 of 2 tasks
NHDaly opened this issue Sep 4, 2019 · 0 comments
Open
1 of 2 tasks

Correctness for Condition Variables (Edge-triggered events) #2

NHDaly opened this issue Sep 4, 2019 · 0 comments

Comments

@NHDaly
Copy link
Owner

NHDaly commented Sep 4, 2019

  • There was a discussion starting here: julep: a @select statement JuliaLang/julia#13763 (comment) that there is a race-condition for edge-triggered events in this implementation that can cause events to be dropped. We should consider whether it's possible to fix this, or if we should simply drop support for Condition variables.

  • (Fixed in Support Threads.Condition variables in Select. #3) There is another problem that I noticed, which is that the current implementation of @select leads to concurrency violations for multithreaded Thread.Conditions, because the wait(::Thread.Condition) occurs on a different task than the user's original lock(::Thread.Condition), so the unlock fails. It's the same as this MWE:

    julia> c = Threads.Condition();
    
    julia> lock(c)
    
    julia> Threads.@spawn wait(c)
    Task (failed) @0x000000011f3bad10
    unlock from wrong thread
    error(::String) at ./error.jl:33
    unlockall(::ReentrantLock) at ./lock.jl:121
    wait(::Base.GenericCondition{ReentrantLock}) at ./condition.jl:105
    (::var"##17#18")() at ./threadingconstructs.jl:113

For the second issue above (wait occurs on a different Task), maybe there is some way to implement a custom wait() function that unlocks the parent thread? This needs to be investigated.

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