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)
|
has_cache_expired(const ThreadData* threadData)
|
||||||
{
|
{
|
||||||
SCHEDULER_ENTER_FUNCTION();
|
SCHEDULER_ENTER_FUNCTION();
|
||||||
|
if (threadData->WentSleepActive() == 0)
|
||||||
|
return false;
|
||||||
CoreEntry* core = threadData->Core();
|
CoreEntry* core = threadData->Core();
|
||||||
bigtime_t activeTime = core->GetActiveTime();
|
bigtime_t activeTime = core->GetActiveTime();
|
||||||
return activeTime - threadData->WentSleepActive() > kCacheExpire;
|
return activeTime - threadData->WentSleepActive() > kCacheExpire;
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ static bool
|
|||||||
has_cache_expired(const ThreadData* threadData)
|
has_cache_expired(const ThreadData* threadData)
|
||||||
{
|
{
|
||||||
SCHEDULER_ENTER_FUNCTION();
|
SCHEDULER_ENTER_FUNCTION();
|
||||||
|
if (threadData->WentSleep() == 0)
|
||||||
|
return false;
|
||||||
return system_time() - threadData->WentSleep() > kCacheExpire;
|
return system_time() - threadData->WentSleep() > kCacheExpire;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ ThreadData::ThreadData(Thread* thread)
|
|||||||
:
|
:
|
||||||
fThread(thread)
|
fThread(thread)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadData::Init()
|
ThreadData::Init()
|
||||||
{
|
{
|
||||||
fPriorityPenalty = 0;
|
|
||||||
fAdditionalPenalty = 0;
|
fAdditionalPenalty = 0;
|
||||||
fEffectivePriority = -1;
|
fEffectivePriority = -1;
|
||||||
|
|
||||||
@@ -40,7 +38,25 @@ ThreadData::Init()
|
|||||||
|
|
||||||
fEnqueued = false;
|
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();
|
SCHEDULER_ENTER_FUNCTION();
|
||||||
|
|
||||||
if (fCore == NULL)
|
if (fCore == NULL || fWentSleep == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return fCore->StarvationCounter() != fWentSleepCount
|
return fCore->StarvationCounter() != fWentSleepCount
|
||||||
|
|||||||
Reference in New Issue
Block a user