scheduler_set_thread_priority: Fix null dereference
This commit is contained in:
@@ -778,11 +778,11 @@ put_back(Thread* thread)
|
|||||||
gPinnedRunQueues[pinnedCPU].PushFront(thread,
|
gPinnedRunQueues[pinnedCPU].PushFront(thread,
|
||||||
get_effective_priority(thread));
|
get_effective_priority(thread));
|
||||||
} else {
|
} else {
|
||||||
int32 previougCore = thread->scheduler_data->previous_core;
|
int32 previousCore = thread->scheduler_data->previous_core;
|
||||||
ASSERT(previougCore >= 0);
|
ASSERT(previousCore >= 0);
|
||||||
|
|
||||||
ASSERT(previougCore == core);
|
ASSERT(previousCore == core);
|
||||||
gRunQueues[previougCore].PushFront(thread,
|
gRunQueues[previousCore].PushFront(thread,
|
||||||
get_effective_priority(thread));
|
get_effective_priority(thread));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -809,9 +809,6 @@ scheduler_set_thread_priority(Thread *thread, int32 priority)
|
|||||||
thread->priority = priority;
|
thread->priority = priority;
|
||||||
|
|
||||||
if (thread->state != B_THREAD_READY) {
|
if (thread->state != B_THREAD_READY) {
|
||||||
cancel_penalty(thread);
|
|
||||||
thread->priority = priority;
|
|
||||||
|
|
||||||
if (thread->state == B_THREAD_RUNNING)
|
if (thread->state == B_THREAD_RUNNING)
|
||||||
update_cpu_priority(thread->cpu->cpu_num, priority);
|
update_cpu_priority(thread->cpu->cpu_num, priority);
|
||||||
return oldPriority;
|
return oldPriority;
|
||||||
@@ -821,11 +818,15 @@ scheduler_set_thread_priority(Thread *thread, int32 priority)
|
|||||||
// a new position.
|
// a new position.
|
||||||
|
|
||||||
bool pinned = thread->pinned_to_cpu > 0;
|
bool pinned = thread->pinned_to_cpu > 0;
|
||||||
int32 previougCPU = thread->previous_cpu->cpu_num;
|
int32 previousCPU;
|
||||||
int32 previougCore = thread->scheduler_data->previous_core;
|
if (pinned) {
|
||||||
ASSERT(previougCore >= 0);
|
ASSERT(thread->previous_cpu != NULL);
|
||||||
|
previousCPU = thread->previous_cpu->cpu_num;
|
||||||
|
}
|
||||||
|
int32 previousCore = thread->scheduler_data->previous_core;
|
||||||
|
ASSERT(previousCore >= 0);
|
||||||
|
|
||||||
SpinLocker runQueueLocker(gCoreEntries[previougCore].fQueueLock);
|
SpinLocker runQueueLocker(gCoreEntries[previousCore].fQueueLock);
|
||||||
|
|
||||||
// the thread might have been already dequeued and is about to start
|
// the thread might have been already dequeued and is about to start
|
||||||
// running once we release its scheduler_lock, in such case we can not
|
// running once we release its scheduler_lock, in such case we can not
|
||||||
@@ -839,9 +840,9 @@ scheduler_set_thread_priority(Thread *thread, int32 priority)
|
|||||||
|
|
||||||
thread->scheduler_data->enqueued = false;
|
thread->scheduler_data->enqueued = false;
|
||||||
if (pinned)
|
if (pinned)
|
||||||
gPinnedRunQueues[previougCPU].Remove(thread);
|
gPinnedRunQueues[previousCPU].Remove(thread);
|
||||||
else
|
else
|
||||||
gRunQueues[previougCore].Remove(thread);
|
gRunQueues[previousCore].Remove(thread);
|
||||||
runQueueLocker.Unlock();
|
runQueueLocker.Unlock();
|
||||||
|
|
||||||
enqueue(thread, true);
|
enqueue(thread, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user