scheduler: Fix core unassignment
This commit is contained in:
parent
7adce94d45
commit
931ce674a9
@ -106,6 +106,7 @@ enqueue(Thread* thread, bool newOne)
|
||||
CoreEntry* targetCore = NULL;
|
||||
if (thread->pinned_to_cpu > 0) {
|
||||
ASSERT(thread->previous_cpu != NULL);
|
||||
ASSERT(threadData->Core() != NULL);
|
||||
targetCPU = &gCPUEntries[thread->previous_cpu->cpu_num];
|
||||
} else if (gSingleCore)
|
||||
targetCore = &gCoreEntries[0];
|
||||
@ -380,14 +381,9 @@ reschedule(int32 nextState)
|
||||
break;
|
||||
case THREAD_STATE_FREE_ON_RESCHED:
|
||||
oldThreadData->Dies();
|
||||
if (gCPU[thisCPU].disabled)
|
||||
oldThreadData->UnassignCore(true);
|
||||
break;
|
||||
default:
|
||||
oldThreadData->GoesAway();
|
||||
if (gCPU[thisCPU].disabled)
|
||||
oldThreadData->UnassignCore(true);
|
||||
|
||||
TRACE("not enqueueing thread %ld into run queue next_state = %ld\n",
|
||||
oldThread->id, nextState);
|
||||
break;
|
||||
@ -399,13 +395,12 @@ reschedule(int32 nextState)
|
||||
ThreadData* nextThreadData;
|
||||
if (gCPU[thisCPU].disabled) {
|
||||
if (!oldThreadData->IsIdle()) {
|
||||
CPURunQueueLocker _(cpu);
|
||||
|
||||
nextThreadData = cpu->PeekIdleThread();
|
||||
cpu->Remove(nextThreadData);
|
||||
|
||||
putOldThreadAtBack = oldThread->pinned_to_cpu == 0;
|
||||
oldThreadData->UnassignCore(true);
|
||||
|
||||
CPURunQueueLocker cpuLocker(cpu);
|
||||
nextThreadData = cpu->PeekIdleThread();
|
||||
cpu->Remove(nextThreadData);
|
||||
} else
|
||||
nextThreadData = oldThreadData;
|
||||
} else {
|
||||
|
@ -199,6 +199,19 @@ ThreadData::ComputeQuantum() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ThreadData::UnassignCore(bool running)
|
||||
{
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
|
||||
ASSERT(fCore != NULL);
|
||||
if (running || fThread->state == B_THREAD_READY)
|
||||
fReady = false;
|
||||
if (!fReady)
|
||||
fCore = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* static */ void
|
||||
ThreadData::ComputeQuantumLengths()
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
inline int32 GetLoad() const { return fNeededLoad; }
|
||||
|
||||
inline CoreEntry* Core() const { return fCore; }
|
||||
inline void UnassignCore(bool running = false);
|
||||
void UnassignCore(bool running = false);
|
||||
|
||||
static void ComputeQuantumLengths();
|
||||
|
||||
@ -501,25 +501,6 @@ ThreadData::UpdateActivity(bigtime_t active)
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
ThreadData::UnassignCore(bool running)
|
||||
{
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
|
||||
ASSERT(fCore != NULL);
|
||||
if (!fReady)
|
||||
fCore = NULL;
|
||||
|
||||
if (running || fThread->state == B_THREAD_READY) {
|
||||
if (gTrackCoreLoad)
|
||||
fCore->UpdateLoad(-fNeededLoad);
|
||||
fReady = false;
|
||||
fThread->state = B_THREAD_SUSPENDED;
|
||||
fCore = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user