Don't hold the wait subsystem lock when acquiring the shared memory process-level lock #123162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the no-pthreads shared memory implementation, we can dispose an unnamed Mutex object when disposing a named Mutex.
When we dispose a named Mutex, we'll acquire the shared memory process-level lock to do so. Then when we dispose the unnamed mutex, we'll acquire the Wait Subsystem lock to be able to handle cleanup. When we lock a named mutex, currently we acquire the process-level lock for the shared memory manager while we still hold the wait subsystem lock (inverse order of lock aquisition -> deadlock). This is not necessary (we aren't going to touch any of the WaitSubsystem data structures at this point) so reorder the locks so we don't lock the wait subsystem lock when acquiring the shared memory lock.
Unblocks dotnet/aspnetcore#65006