diff --git a/src/system/kernel/scheduler/low_latency.cpp b/src/system/kernel/scheduler/low_latency.cpp index 51381c3ac8..3b567cbae5 100644 --- a/src/system/kernel/scheduler/low_latency.cpp +++ b/src/system/kernel/scheduler/low_latency.cpp @@ -164,7 +164,7 @@ scheduler_mode_operations gSchedulerLowLatencyMode = { 100, { 2, 25 }, - 50000, + 10000, switch_to_mode, set_cpu_enabled, diff --git a/src/system/kernel/scheduler/scheduler_thread.cpp b/src/system/kernel/scheduler/scheduler_thread.cpp index 63f4450b6e..a16cf3259c 100644 --- a/src/system/kernel/scheduler/scheduler_thread.cpp +++ b/src/system/kernel/scheduler/scheduler_thread.cpp @@ -217,14 +217,14 @@ ThreadData::ComputeQuantum() quantum += fStolenTime; fStolenTime = 0; - int32 threadCount = (fCore->ThreadCount() + 1) / fCore->CPUCount(); - threadCount = max_c(threadCount, 1); - - quantum = std::min(gCurrentMode->maximum_latency / threadCount, quantum); - quantum = std::max(quantum, gCurrentMode->minimal_quantum); + int32 threadCount = fCore->ThreadCount() / fCore->CPUCount(); + if (threadCount >= 1) { + quantum + = std::min(gCurrentMode->maximum_latency / threadCount, quantum); + quantum = std::max(quantum, gCurrentMode->minimal_quantum); + } fTimeLeft = quantum; - return quantum; } diff --git a/src/system/kernel/scheduler/scheduler_thread.h b/src/system/kernel/scheduler/scheduler_thread.h index 896692095b..92e5f2353a 100644 --- a/src/system/kernel/scheduler/scheduler_thread.h +++ b/src/system/kernel/scheduler/scheduler_thread.h @@ -44,11 +44,11 @@ public: inline int32 GetEffectivePriority() const; + inline bool IsCPUBound() const; + inline void CancelPenalty(); inline bool ShouldCancelPenalty() const; - inline bool IsCPUBound() const { return fAdditionalPenalty != 0; } - bool ChooseCoreAndCPU(CoreEntry*& targetCore, CPUEntry*& targetCPU); @@ -85,7 +85,7 @@ public: static void ComputeQuantumLengths(); private: - inline void _IncreasePenalty(); + inline void _IncreasePenalty(bool strong); inline int32 _GetPenalty() const; void _ComputeEffectivePriority() const; @@ -175,7 +175,7 @@ ThreadData::GetEffectivePriority() const inline void -ThreadData::_IncreasePenalty() +ThreadData::_IncreasePenalty(bool strong) { SCHEDULER_ENTER_FUNCTION(); @@ -187,12 +187,14 @@ ThreadData::_IncreasePenalty() TRACE("increasing thread %ld penalty\n", fThread->id); fReceivedPenalty = true; - int32 oldPenalty = fPriorityPenalty++; + int32 oldPenalty = fPriorityPenalty; + if (strong) + fPriorityPenalty++; ASSERT(fThread->priority - oldPenalty >= B_LOWEST_ACTIVE_PRIORITY); const int kMinimalPriority = _GetMinimalPriority(); - if (fThread->priority - oldPenalty <= kMinimalPriority) { + if (!strong || fThread->priority - oldPenalty <= kMinimalPriority) { fPriorityPenalty = oldPenalty; fAdditionalPenalty++; } @@ -201,6 +203,14 @@ ThreadData::_IncreasePenalty() } +inline bool +ThreadData::IsCPUBound() const +{ + SCHEDULER_ENTER_FUNCTION(); + return fAdditionalPenalty != 0 && fPriorityPenalty != 0; +} + + inline void ThreadData::CancelPenalty() { @@ -255,7 +265,7 @@ ThreadData::GoesAway() SCHEDULER_ENTER_FUNCTION(); if (!fReceivedPenalty) - _IncreasePenalty(); + _IncreasePenalty(false); fHasSlept = true; fLastInterruptTime = 0; @@ -400,7 +410,7 @@ ThreadData::HasQuantumEnded(bool wasPreempted, bool hasYielded) if (fTimeLeft == 0) { if (!fReceivedPenalty && !fHasSlept) - _IncreasePenalty(); + _IncreasePenalty(true); fReceivedPenalty = false; fHasSlept = false; }