monad-par icon indicating copy to clipboard operation
monad-par copied to clipboard

Chase-Lev queue looks like trouble

Open treeowl opened this issue 7 years ago • 2 comments
trafficstars

Aside from all their other devilish subtleties, it appears to be that Chase-Lev queues don't completely guarantee that left and right pops don't both take the last queue element. If that happens here, I believe two threads could both try to fill the same IVar, in which case the second one will fill the IVar with an exception thunk (and then throw an exception). To fix this, we'd need put_ to take care to leave the IVar value alone when it's full. That's easy enough, but I don't think it's nearly enough: what do we do about the exception? A particularly nasty case involves two IVars, A and B, and two copies of the same thread, P and Q. Suppose P and Q each spawn threads to fill A and B, and those happen to do so in the opposite orders. Then P will die because B is full, and Q will die because A is full. I therefore believe that when Chase-Lev queues are enabled, non-determinism errors should be disabled.

treeowl avatar Jul 20 '18 22:07 treeowl

Hrmm... Maybe I'm wrong... the implementation we use may be stronger than the original paper. This stuff looks extremely subtle.

treeowl avatar Jul 21 '18 20:07 treeowl

It is extremely subtle. Perhaps this issue belongs over on the chaselev-deque repo instead?

simonmar avatar Jul 23 '18 07:07 simonmar