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