diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index 0480f93dfa35b1..d6c50b305d1e06 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -421,7 +421,6 @@ public int Count (Environment.ProcessorCount + (ProcessorsPerAssignableWorkItemQueue - 1)) / ProcessorsPerAssignableWorkItemQueue; private bool _loggingEnabled; - private bool _dispatchNormalPriorityWorkFirst; // SOS's ThreadPool command depends on the following names internal readonly WorkQueue workItems = new WorkQueue(); @@ -840,32 +839,6 @@ public long GlobalCount // Dispatch (if YieldFromDispatchLoop is true), or performing periodic activities public const uint DispatchQuantumMs = 30; - private static object? DequeueWithPriorityAlternation(ThreadPoolWorkQueue workQueue, ThreadPoolWorkQueueThreadLocals tl, out bool missedSteal) - { - object? workItem = null; - - // Alternate between checking for high-prioriy and normal-priority work first, that way both sets of work - // items get a chance to run in situations where worker threads are starved and work items that run also - // take over the thread, sustaining starvation. For example, when worker threads are continually starved, - // high-priority work items may always be queued and normal-priority work items may not get a chance to run. - bool dispatchNormalPriorityWorkFirst = workQueue._dispatchNormalPriorityWorkFirst; - if (dispatchNormalPriorityWorkFirst && !tl.workStealingQueue.CanSteal) - { - workQueue._dispatchNormalPriorityWorkFirst = !dispatchNormalPriorityWorkFirst; - WorkQueue queue = - s_assignableWorkItemQueueCount > 0 ? tl.assignedGlobalWorkItemQueue : workQueue.workItems; - if (!queue.TryDequeue(out workItem) && s_assignableWorkItemQueueCount > 0) - { - workQueue.workItems.TryDequeue(out workItem); - } - } - - missedSteal = false; - workItem ??= workQueue.Dequeue(tl, ref missedSteal); - - return workItem; - } - /// /// Dispatches work items to this thread. /// @@ -877,7 +850,8 @@ internal static bool Dispatch() { ThreadPoolWorkQueue workQueue = ThreadPool.s_workQueue; ThreadPoolWorkQueueThreadLocals tl = workQueue.GetOrCreateThreadLocals(); - object? workItem = DequeueWithPriorityAlternation(workQueue, tl, out bool missedSteal); + bool missedSteal = false; + object? workItem = workQueue.Dequeue(tl, ref missedSteal); if (workItem == null) { // Missing a steal means there may be an item that we were unable to get.