iu-parfunc / lvars

The LVish Haskell library
http://hackage.haskell.org/package/lvish
80 stars 14 forks source link

freezeLVAfter doesn't have a dedup check, GET_ONCE is not complete #98

Open rrnewton opened 10 years ago

rrnewton commented 10 years ago

The principle of the GET_ONCE -fgetonce option was to make sure that the main continuation of the application never gets duplicated. Handlers can still get duplicated, but blocking operations such as getLV must not duplicate their continuation.

However, there was an oversight. getLV is not the only operation that could duplicate its continuation. quiesce is another. For example:

|3| #1 of 2: wrkr0  [dbg-lvish] quiesce: poll count, pool identity= 12/11 transient cnt 1
|3| #2 of 2: wrkr1  [dbg-lvish] -> Quiescent now.. waking conts, pool identity= 12/11 transient cnt 0
\7| Starting pushWork on worker 1
|3| #1 of 2: wrkr0  [dbg-lvish] already quiesced, remove token from bag, pool identity= 12/11 transient cnt 0
|5| #2 of 2: wrkr1  [dbg-lvish] freezeLV: atomic modify status to Freezing, lv 10 on worker 1
|7| #2 of 2: wrkr1  [dbg-lvish] freezeLV: begin busy-wait for putter status, lv 10 on worker 1
|7| #2 of 2: wrkr1  [dbg-lvish] freezeLV: calling each listener's onFreeze, lv 10 on worker 1
|5| #1 of 2: wrkr0  [dbg-lvish] freezeLV: atomic modify status to Freezing, lv 10 on worker 0

Here we see both worker one and zero beginning the continuation of the quiesce.