-
Notifications
You must be signed in to change notification settings - Fork 115
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
Read-Write Locks #735
Read-Write Locks #735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't read in detail, looks generally good, but
- Using a FFI-based solution might be better, especially if it can take advantage of futexes on Linux yet be portable to other systems... sigh.
- There is no documentation.
FFI is no go, we need ro play nice with the gambit scheduler. |
added documentation. |
the word preempt is just wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a short comment that this form of "unlock" relocks is in order. I admit I am not familiar enough with this primitive.
Actually I was wrong and you are right that we need to relock at the top of the loop: http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php?title=Documentation:Procedure_mutex-unlock! |
reading the docs every now and then is good; bug averted.
Use two separate convars, one for readers and one for writers. Readers wait on the rcv, while writes wait on the wcv. When the read lock is relinquished, if there are writers waiting we wake up exactly one with signal. When the write lock is relinquished, if there are writers waiting we wake up exactly one with signal; otherwise we wake up all readers.
fingers crossed that CI won't completely mess up the timings.
it can help with debugging.
Having to re-lock and retry suggests that you should maintain an explicit queue rather than busy poll, and then use a condition variable to wake up the waiting writer or readers. |
there is no busy poll, and the two condvars eliminate the contention. |
Sorely missing them! Cherry picked from #728