scheduler: Inherit penalty and core from creator thread
This commit is contained in:
@@ -35,7 +35,8 @@ static bool
|
||||
has_cache_expired(const ThreadData* threadData)
|
||||
{
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
|
||||
if (threadData->WentSleepActive() == 0)
|
||||
return false;
|
||||
CoreEntry* core = threadData->Core();
|
||||
bigtime_t activeTime = core->GetActiveTime();
|
||||
return activeTime - threadData->WentSleepActive() > kCacheExpire;
|
||||
|
||||
@@ -41,6 +41,8 @@ static bool
|
||||
has_cache_expired(const ThreadData* threadData)
|
||||
{
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
if (threadData->WentSleep() == 0)
|
||||
return false;
|
||||
return system_time() - threadData->WentSleep() > kCacheExpire;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,12 @@ ThreadData::ThreadData(Thread* thread)
|
||||
:
|
||||
fThread(thread)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ThreadData::Init()
|
||||
{
|
||||
fPriorityPenalty = 0;
|
||||
fAdditionalPenalty = 0;
|
||||
fEffectivePriority = -1;
|
||||
|
||||
@@ -40,7 +38,25 @@ ThreadData::Init()
|
||||
|
||||
fEnqueued = false;
|
||||
|
||||
fCore = NULL;
|
||||
Thread* currentThread = thread_get_current_thread();
|
||||
ASSERT(currentThread != NULL);
|
||||
if (!thread_is_idle_thread(currentThread)) {
|
||||
ThreadData* currentThreadData = currentThread->scheduler_data;
|
||||
int32 penalty = currentThreadData->fPriorityPenalty;
|
||||
|
||||
int32 minimalPriority = _GetMinimalPriority();
|
||||
if (fThread->priority - penalty >= minimalPriority)
|
||||
fPriorityPenalty = penalty;
|
||||
else
|
||||
fPriorityPenalty = fThread->priority - minimalPriority;
|
||||
|
||||
fCore = currentThreadData->fCore;
|
||||
} else {
|
||||
fPriorityPenalty = 0;
|
||||
fAdditionalPenalty = 0;
|
||||
|
||||
fCore = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ ThreadData::ShouldCancelPenalty() const
|
||||
{
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
|
||||
if (fCore == NULL)
|
||||
if (fCore == NULL || fWentSleep == 0)
|
||||
return false;
|
||||
|
||||
return fCore->StarvationCounter() != fWentSleepCount
|
||||
|
||||
Reference in New Issue
Block a user