scheduler: Inherit penalty and core from creator thread

This commit is contained in:
Pawel Dziepak 2013-12-31 00:59:29 +01:00
parent 7c92dffeef
commit 2d52abbd5d
4 changed files with 24 additions and 5 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -195,7 +195,7 @@ ThreadData::ShouldCancelPenalty() const
{
SCHEDULER_ENTER_FUNCTION();
if (fCore == NULL)
if (fCore == NULL || fWentSleep == 0)
return false;
return fCore->StarvationCounter() != fWentSleepCount