[threading] Change request async suspend to return 3 states instead of one to account...
commitfe784fbca9bff373f3580ba6fe77a92aa001a2a8
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 2 Feb 2015 16:04:37 +0000 (2 11:04 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 11 Mar 2015 16:26:37 +0000 (11 12:26 -0400)
tree6a99ae52a4607f2029e511f5febfb908fa537157
parent296347fc8898edfca59157841c2fd11f78f9dc49
[threading] Change request async suspend to return 3 states instead of one to account for async racing to the middle of a self suspend.

When begin async suspend lands in STATE_SUSPEND_IN_PROGRESS, the initiator don't need to perform an async suspend, it just needs to wait.

If a self suspend is promoted to an async suspend, it must be added to the pending ops set. This ensure that it will be waited otherwise
the suspend initiator might witness an unfinished self suspend and assert when fetching the thread state.

The alternative would be to change finish async suspend to account for the possibility of witnessing STATE_SUSPEND_PROMOTED_TO_ASYNC.

Solving this way requires less async suspends and doesn't increase the valid state space.
mono/utils/mono-threads-state-machine.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h