Remove dead prioritized-wait path from Unix WaitSubsystem#129081
Merged
Conversation
Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove functionality related to prioritized waits in WaitSubsystem
Remove dead prioritized-wait path from Unix WaitSubsystem
Jun 6, 2026
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
VSadov
approved these changes
Jun 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the Unix WaitSubsystem internals in System.Private.CoreLib by removing the unused “prioritized wait” plumbing (prioritize parameter and the LIFO registration path). Wait registration now consistently uses the existing FIFO waiter-list behavior, with no new public surface area.
Changes:
- Removed the
prioritizeparameter from internal wait entry points (Wait,SignalAndWait),IWaitableObject.Wait_Locked, and related helpers/implementations. - Simplified wait registration by removing the prioritized/LIFO branch and deleting
RegisterPrioritizedWait, always registering waiters via FIFORegisterWait. - Updated in-code references/comments to match the new
RegisterWait(int, bool)signature.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.Unix.cs | Removes prioritize from internal wait entry points and updates call sites/forwarding. |
| src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.HandleManager.Unix.cs | Aligns IWaitableObject.Wait_Locked and the Wait extension method with the new signature. |
| src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.WaitableObject.Unix.cs | Drops prioritize from wait implementations and updates RegisterWait call sites. |
| src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.ThreadWaitInfo.Unix.cs | Removes the prioritized/LIFO registration path and deletes RegisterPrioritizedWait. |
| src/libraries/System.Private.CoreLib/src/System/Threading/NamedMutex.Unix.cs | Updates the NamedMutex Wait_Locked implementation signature to match the interface. |
jkotas
approved these changes
Jun 7, 2026
Member
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change removes the unused
prioritizewait path from UnixWaitSubsysteminternals. All wait registration now follows the existing FIFO behavior, with no public API impact.Entry-point cleanup (
WaitSubsystem.Unix.cs)prioritizefrom internalWait(...)andSignalAndWait(...)entry points.prioritize: falseforwarding at all internal call sites (NewMutex,CreateNamedMutex, single/multi-handle waits).Interface and implementation signature alignment
IWaitableObject.Wait_Locked(...)inWaitSubsystem.HandleManager.Unix.csto removeprioritize.IWaitableObjectWait(...)extension method to removeprioritize.WaitSubsystem.WaitableObject.Unix.csNamedMutex.Unix.csWait registration simplification (
WaitSubsystem.ThreadWaitInfo.Unix.cs)RegisterWait(int waitedCount, bool prioritize, bool isWaitForAll)toRegisterWait(int waitedCount, bool isWaitForAll).RegisterWait(...).WaitedListNode.RegisterPrioritizedWait(...).Comment/reference consistency
RegisterWaitshape.Original prompt
Goal
Remove all functionality related to prioritized waits in the Unix
WaitSubsystem. Theprioritizeparameter exists on internalWaitSubsystemAPIs but is effectively dead — every reachable call site passesprioritize: false(or uses an overload that hard‑codes it). Remove the parameter, the supporting plumbing, and the prioritized‑wait code path so the wait subsystem only supports fair (FIFO) waits.Background
WaitSubsystemis the managed Unix implementation ofWaitHandle/EventWaitHandle/Semaphore/Mutex. It is located under:src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.Unix.cssrc/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.HandleManager.Unix.cssrc/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.ThreadWaitInfo.Unix.cssrc/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.WaitableObject.Unix.cssrc/libraries/System.Private.CoreLib/src/System/Threading/NamedMutex.Unix.cs(also defines anIWaitableObjectimplementation withWait_Locked)A
prioritizeboolean is plumbed through these APIs. Whentrue,ThreadWaitInfo.RegisterWaitcallsWaitedListNode.RegisterPrioritizedWaitinstead ofRegisterWait, which inserts the waiter at the head of the waiters list (LIFO) instead of the tail (FIFO). No caller in the repo ever passesprioritize: true— see analysis below.Concrete changes
1.
WaitSubsystem.Unix.csRemove the
prioritizeparameter from the two public entry points and their forwarders:public static int Wait(IWaitableObject waitableObject, int timeoutMilliseconds, bool interruptible = true, bool prioritize = false)— dropprioritizeparameter; update body to no longer pass it.public static int SignalAndWait(IWaitableObject waitableObjectToSignal, IWaitableObject waitableObjectToWaitOn, int timeoutMilliseconds, bool interruptible = true, bool prioritize = false)— dropprioritize; update body to no longer pass it toWait_Locked.Also remove the now‑redundant
prioritize: falsenamed arguments at all internal call sites in this file (NewMutex,CreateNamedMutex, theWait(ReadOnlySpan<IntPtr>, …)overload calls toWaitableObject.WaitandnamedMutex.Wait, etc.).2.
WaitSubsystem.HandleManager.Unix.csinterface IWaitableObject, removeprioritizefromWait_Locked's signature:int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize, ref LockHolder lockHolder);int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, ref LockHolder lockHolder);Waitextension method onIWaitableObject, drop theprioritizeparameter and stop forwarding it.3.
WaitSubsystem.WaitableObject.Unix.csprioritizefrom the signatures of bothWaitableObject.Wait_Locked(...)and the staticWaitableObject.Wait(WaitableObject?[]? waitableObjects, int count, bool waitForAll, ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize).waitInfo.RegisterWait(...)accordingly (see WIP: Initial CoreCLR CI pipeline in the composite repo #4).4.
WaitSubsystem.ThreadWaitInfo.Unix.cspublic void RegisterWait(int waitedCount, bool prioritize, bool isWaitForAll)topublic void RegisterWait(int waitedCount, bool isWaitForAll).if (prioritize) { … RegisterPrioritizedWait(…) } else { … RegisterWait(…) }branch — always call the FIFORegisterWaitpath.WaitedListNode.RegisterPrioritizedWait(WaitableObject waitableObject)method entirely.5.
NamedMutex.Unix.csNamedMutex.Wait_Lockedmethod signature to match the newIWaitableObjectinterface (dropprioritize). The method body already ignores the parameter.6. Eliminate all uses of
prioritizenamed/positional arguments throughout the affected filesAfter the signature changes, fix up call sites and named arguments such as
prioritize: falseso things compile cleanly. The repo currently has noprioritize: truecall sites.7. Adjust the design-doc comments in
WaitSubsystem.Unix.csThe big doc comment at the top of
WaitSubsystem.Unix.csdescribes the design goals, including wait release fairness. No content changes are needed there since we're keeping the FIFO behavior, but please verify no comment in the affected files still references "prioritized" waits /RegisterPrioritizedWait/ theprioritizeparameter. Update or remove any such stale comments.Reference: current call sites of the affected entry points
These are the only callers in the repo, and none pass
prioritize: true:WaitHandle.Unix.cs—WaitOneCore,WaitMultipleIgnoringSyncContextCore,SignalAndWaitCoreuse overloads withoutprioritize(Wait(IntPtr, int, bool),Wait(ReadOnlySpan<IntPtr>, bool, int),SignalAndWait(IntPtr, IntPtr, int)). These do not n...This pull request was created from Copilot chat.