[threading] Split unwind state into sync and async.
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 2 Feb 2015 16:04:37 +0000 (11:04 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 11 Mar 2015 16:26:37 +0000 (12:26 -0400)
commit518dee183763b7b7e33baeaf0972f37f2d5d8cd1
tree3680ac09468e8510752b1588612ac94a58581da2
parentfe784fbca9bff373f3580ba6fe77a92aa001a2a8
[threading] Split unwind state into sync and async.

Having a single unwind state means writes to it must be synchronized between sync and async suspend. We can't
have the state be broken as it could lead to bad unwinding or GC marking.

The original solution was to have an additional state in the self suspend path that signals it's writing to the
thread state and thus any async suspend must give up and let it finish. This ended up been overly complicated
as this requires two additional states instead.

By having a pair of unwind states both can write concurrently without the fear of clashing. This makes fetching the state
a little bit trickier but worth the trouble.

The simplified design has a much smaller state space, which is easier to reason about.
mono/metadata/sgen-stw.c
mono/metadata/threads.c
mono/mini/debugger-agent.c
mono/mini/exceptions-amd64.c
mono/utils/mono-threads-mach.c
mono/utils/mono-threads-posix.c
mono/utils/mono-threads-state-machine.c
mono/utils/mono-threads-windows.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h