-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Port the Shared Mutex logic from CoreCLR PAL to work alongside the managed wait subsystem #117635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
02db598
Start working on porting shared mutexes to managed in a line-by-line …
jkoritzinsky b855928
Fill out a lot of the rest of the logic.
jkoritzinsky 9ec79b8
Finish filling in the holes in the shared memory impl.
jkoritzinsky 74d6db7
Fix process-level lock handling
jkoritzinsky ab7b688
Split into two files and fill out other entrypoints
jkoritzinsky 5c59aad
Move the named mutex impl to a runtime that has the wait subsystem.
jkoritzinsky 40ec2d7
Finish integrating with the wait subsystem entry points and bring bac…
jkoritzinsky 4904eb7
Enable tests
jkoritzinsky 194ea40
Fix various problems found by tests and adjust locking to actually wo…
jkoritzinsky 6495e44
Adjust PThread setting default based on testing with our cross-build …
jkoritzinsky 189a71e
Handle EOWNERDEAD
jkoritzinsky 7cfb931
Add stubs to wasi
jkoritzinsky 69fe72f
Don't use cross-process mutexes on mobile platforms. Only use the in-…
jkoritzinsky ee0f7ce
Move the whole "shared data" struct for the pthread mutex impl across…
jkoritzinsky 9787f15
Do a little cleanup
jkoritzinsky bce3af6
Remove unused member
jkoritzinsky 36bd5c0
Cleanup projitems
jkoritzinsky 182c57a
Cleanup libraries pal a little
jkoritzinsky 61aabd4
Rename and split out the "unsupported" impl
jkoritzinsky ba0ecc2
Rename as requested
jkoritzinsky a2d9121
Remove unused AcquirePthreadMutexWithTimeout impl
jkoritzinsky 0cfacc1
Fix failure on the "unsupported" path
jkoritzinsky 5cbaa62
Add arg references.
jkoritzinsky 05cecb6
Use the correct API for locking with a specific clock.
jkoritzinsky e4d595d
Mark noreturn for debug builds to satisfy compiler
jkoritzinsky d1dca10
Allow abandonment from the finalizer thread. Sometimes we can only cl…
jkoritzinsky 1c7c39d
Add timeout for one test that was missing it. Fix named mutex tests o…
jkoritzinsky e23ccc5
Fix CoreCLR and NAOT builds
jkoritzinsky 510efcf
Refactor how named mutex ownership is tracked for abandonment to make…
jkoritzinsky 895af9e
Update comsynchronizable.cpp
jkoritzinsky 4e80270
Use a Mutex for process-level locking in the no-pthreads implementati…
jkoritzinsky 79c7812
PR feedback
jkoritzinsky 625b8d6
Do a little bit of cleanup on formatting
jkoritzinsky bccae1d
Various build fixes
jkoritzinsky 0d764fd
Don't release when abandoning as we don't know our thread and we can'…
jkoritzinsky c5f32cb
Remove unintended whitespace change
jkoritzinsky 47bd54c
Fix indent
jkoritzinsky 8ff75cd
Various PR feedback
jkoritzinsky c17aec2
Make CurrentThreadIsFinalizerThread an FCall on CoreCLR and share code
jkoritzinsky 875eb1a
Remove qcall entrypoint
jkoritzinsky 5e28e5a
Add missing using
jkoritzinsky a18d6c8
Apply suggestions from code review
jkoritzinsky 12936de
Adjust code to pass new tests being added in another PR
jkoritzinsky 747eaad
Fix name for NAOT import
jkoritzinsky d5960a7
Use Environment.SystemPageSize
jkoritzinsky fb49a22
Merge branch 'main' of https://github.com/dotnet/runtime into shared-…
jkoritzinsky a9d94ff
Fix test for slashes in name
jkoritzinsky 029d73b
Use existing PlatformDetection options for named mutex feature detection
jkoritzinsky 5331532
PR feedback
jkoritzinsky ca516d7
Apply suggestions from code review
jkoritzinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelCrossProcessMutex.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal static partial class Interop | ||
| { | ||
| internal static unsafe partial class Sys | ||
| { | ||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_Init", SetLastError = true)] | ||
| internal static partial int LowLevelCrossProcessMutex_Init(void* mutex); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_Acquire", SetLastError = true)] | ||
| internal static partial int LowLevelCrossProcessMutex_Acquire(void* mutex, int timeoutMilliseconds); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_Release", SetLastError = true)] | ||
| internal static partial int LowLevelCrossProcessMutex_Release(void* mutex); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_Destroy", SetLastError = true)] | ||
| internal static partial int LowLevelCrossProcessMutex_Destroy(void* mutex); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_Size")] | ||
| [SuppressGCTransition] | ||
| internal static partial int LowLevelCrossProcessMutex_Size(); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_GetOwnerProcessAndThreadId", SetLastError = true)] | ||
| [SuppressGCTransition] | ||
| internal static partial void LowLevelCrossProcessMutex_GetOwnerProcessAndThreadId(void* mutex, out uint processId, out uint threadId); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_SetOwnerProcessAndThreadId", SetLastError = true)] | ||
| [SuppressGCTransition] | ||
| internal static partial void LowLevelCrossProcessMutex_SetOwnerProcessAndThreadId(void* mutex, uint processId, uint threadId); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_IsAbandoned", SetLastError = true)] | ||
| [SuppressGCTransition] | ||
| [return: MarshalAs(UnmanagedType.U1)] | ||
| internal static partial bool LowLevelCrossProcessMutex_IsAbandoned(void* mutex); | ||
|
|
||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelCrossProcessMutex_SetAbandoned", SetLastError = true)] | ||
| [SuppressGCTransition] | ||
| internal static partial void LowLevelCrossProcessMutex_SetAbandoned(void* mutex, [MarshalAs(UnmanagedType.U1)] bool abandoned); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.