From 9caf7f4fb95b33daa9e2caf2267c2636ba24ce49 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Wed, 27 Nov 2013 04:15:36 +0100 Subject: [PATCH] scheduler: Update estimate_max_scheduling_latency() --- src/system/kernel/scheduler/scheduler.cpp | 23 +++++++++++-------- .../kernel/scheduler/scheduler_common.h | 2 -- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp index a265671483..6f105f630a 100644 --- a/src/system/kernel/scheduler/scheduler.cpp +++ b/src/system/kernel/scheduler/scheduler.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -1768,18 +1769,20 @@ _user_estimate_max_scheduling_latency(thread_id id) } BReference threadReference(thread, true); - // TODO: This is probably meant to be called periodically to return the - // current estimate depending on the system usage; we return fixed estimates - // per thread priority, though. + int32 core = thread->scheduler_data->previous_core; + if (core == -1) + core = get_random() % gCoreCount; - if (thread->priority >= B_REAL_TIME_DISPLAY_PRIORITY) - return kMinThreadQuantum / 4; - if (thread->priority >= B_DISPLAY_PRIORITY) - return kMinThreadQuantum; - if (thread->priority < B_NORMAL_PRIORITY) - return 2 * kMaxThreadQuantum; + int32 threadCount = gCoreEntries[core].fThreadCount; + if (gCoreEntries[core].fCPUCount > 0) + threadCount /= gCoreEntries[core].fCPUCount; - return 2 * kMinThreadQuantum; + if (get_effective_priority(thread) > 0) { + threadCount -= threadCount * THREAD_MAX_SET_PRIORITY + / get_effective_priority(thread); + } + + return max_c(threadCount * kThreadQuantum, kThreadQuantum / 5); } diff --git a/src/system/kernel/scheduler/scheduler_common.h b/src/system/kernel/scheduler/scheduler_common.h index c8037758a0..1fdb26f8f1 100644 --- a/src/system/kernel/scheduler/scheduler_common.h +++ b/src/system/kernel/scheduler/scheduler_common.h @@ -30,8 +30,6 @@ namespace Scheduler { const bigtime_t kThreadQuantum = 1000; -const bigtime_t kMinThreadQuantum = 3000; -const bigtime_t kMaxThreadQuantum = 10000; const bigtime_t kCacheExpire = 100000;