From 9363e99b19d122db7d6684b06d7240fb73255cd2 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Tue, 8 Oct 2013 20:21:35 +0200 Subject: [PATCH] kernel: Remove Thread::next_priority --- headers/private/kernel/thread_types.h | 1 - .../kernel/scheduler/scheduler_affine.cpp | 6 ++---- .../kernel/scheduler/scheduler_simple.cpp | 5 ++--- .../kernel/scheduler/scheduler_simple_smp.cpp | 6 ++---- src/system/kernel/thread.cpp | 17 +++++++---------- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/headers/private/kernel/thread_types.h b/headers/private/kernel/thread_types.h index 637c5bed42..3e4ec90261 100644 --- a/headers/private/kernel/thread_types.h +++ b/headers/private/kernel/thread_types.h @@ -422,7 +422,6 @@ struct Thread : TeamThreadIteratorEntry, KernelReferenceable, timer alarm; // protected by scheduler lock char name[B_OS_NAME_LENGTH]; // protected by fLock int32 priority; // protected by scheduler lock - int32 next_priority; // protected by scheduler lock int32 io_priority; // protected by fLock int32 state; // protected by scheduler lock int32 next_state; // protected by scheduler lock diff --git a/src/system/kernel/scheduler/scheduler_affine.cpp b/src/system/kernel/scheduler/scheduler_affine.cpp index 059df02654..f5b7294b10 100644 --- a/src/system/kernel/scheduler/scheduler_affine.cpp +++ b/src/system/kernel/scheduler/scheduler_affine.cpp @@ -154,7 +154,7 @@ affine_enqueue_in_run_queue(Thread *thread) } else { Thread *curr, *prev; for (curr = sRunQueue[targetCPU], prev = NULL; curr - && curr->priority >= thread->next_priority; + && curr->priority >= thread->priority; curr = curr->queue_next) { if (prev) prev = prev->queue_next; @@ -173,8 +173,6 @@ affine_enqueue_in_run_queue(Thread *thread) thread->scheduler_data->fLastQueue = targetCPU; } - thread->next_priority = thread->priority; - // notify listeners NotifySchedulerListeners(&SchedulerListener::ThreadEnqueuedInRunQueue, thread); @@ -304,7 +302,7 @@ affine_set_thread_priority(Thread *thread, int32 priority) thread = dequeue_from_run_queue(prev, targetCPU); // set priority and re-insert - thread->priority = thread->next_priority = priority; + thread->priority = priority; affine_enqueue_in_run_queue(thread); } diff --git a/src/system/kernel/scheduler/scheduler_simple.cpp b/src/system/kernel/scheduler/scheduler_simple.cpp index 3601c0a6a4..99818d8f4e 100644 --- a/src/system/kernel/scheduler/scheduler_simple.cpp +++ b/src/system/kernel/scheduler/scheduler_simple.cpp @@ -152,7 +152,7 @@ simple_get_effective_priority(Thread* thread) ASSERT(schedulerThreadData->priority_penalty >= 0); ASSERT(effectivePriority >= B_LOWEST_ACTIVE_PRIORITY); - return min_c(effectivePriority, thread->next_priority); + return effectivePriority; } @@ -217,7 +217,6 @@ simple_enqueue_in_run_queue(Thread* thread) else sRunQueue->PushBack(thread, threadPriority); - thread->next_priority = thread->priority; schedulerThreadData->cpu_bound = true; schedulerThreadData->time_left = 0; schedulerThreadData->stolen_time = 0; @@ -267,7 +266,7 @@ simple_set_thread_priority(Thread* thread, int32 priority) // set priority and re-insert simple_cancel_penalty(thread); - thread->priority = thread->next_priority = priority; + thread->priority = priority; simple_enqueue_in_run_queue(thread); } diff --git a/src/system/kernel/scheduler/scheduler_simple_smp.cpp b/src/system/kernel/scheduler/scheduler_simple_smp.cpp index 66656120f0..092fd70176 100644 --- a/src/system/kernel/scheduler/scheduler_simple_smp.cpp +++ b/src/system/kernel/scheduler/scheduler_simple_smp.cpp @@ -118,7 +118,7 @@ enqueue_in_run_queue(Thread *thread) Thread *curr, *prev; for (curr = sRunQueue, prev = NULL; curr - && curr->priority >= thread->next_priority; + && curr->priority >= thread->priority; curr = curr->queue_next) { if (prev) prev = prev->queue_next; @@ -134,8 +134,6 @@ enqueue_in_run_queue(Thread *thread) else sRunQueue = thread; - thread->next_priority = thread->priority; - if (thread->priority != B_IDLE_PRIORITY) { // Select a CPU for the thread to run on. It's not certain that the // thread will actually run on it, but we will notify the CPU to @@ -211,7 +209,7 @@ set_thread_priority(Thread *thread, int32 priority) sRunQueue = item->queue_next; // set priority and re-insert - thread->priority = thread->next_priority = priority; + thread->priority = priority; enqueue_in_run_queue(thread); } diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 0c785a22a5..e2dc89c439 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -167,7 +167,6 @@ Thread::Thread(const char* name, thread_id threadID, struct cpu_ent* cpu) team_next(NULL), queue_next(NULL), priority(-1), - next_priority(-1), io_priority(-1), cpu(cpu), previous_cpu(NULL), @@ -901,7 +900,6 @@ thread_create_thread(const ThreadCreationAttributes& attributes, bool kernel) // available for deinitialization thread->priority = attributes.priority == -1 ? B_NORMAL_PRIORITY : attributes.priority; - thread->next_priority = thread->priority; thread->state = B_THREAD_SUSPENDED; thread->next_state = B_THREAD_SUSPENDED; @@ -1427,7 +1425,7 @@ make_thread_unreal(int argc, char **argv) continue; if (thread->priority > B_DISPLAY_PRIORITY) { - thread->priority = thread->next_priority = B_NORMAL_PRIORITY; + thread->priority = B_NORMAL_PRIORITY; kprintf("thread %" B_PRId32 " made unreal\n", thread->id); } } @@ -1463,7 +1461,7 @@ set_thread_prio(int argc, char **argv) Thread* thread = it.Next();) { if (thread->id != id) continue; - thread->priority = thread->next_priority = prio; + thread->priority = prio; kprintf("thread %" B_PRId32 " set to priority %" B_PRId32 "\n", id, prio); found = true; break; @@ -1702,9 +1700,8 @@ _dump_thread_info(Thread *thread, bool shortInfo) kprintf("name: \"%s\"\n", thread->name); kprintf("hash_next: %p\nteam_next: %p\nq_next: %p\n", thread->hash_next, thread->team_next, thread->queue_next); - kprintf("priority: %" B_PRId32 " (next %" B_PRId32 ", " - "I/O: %" B_PRId32 ")\n", thread->priority, thread->next_priority, - thread->io_priority); + kprintf("priority: %" B_PRId32 " (I/O: %" B_PRId32 ")\n", + thread->priority, thread->io_priority); kprintf("state: %s\n", state_to_text(thread, thread->state)); kprintf("next_state: %s\n", state_to_text(thread, thread->next_state)); kprintf("cpu: %p ", thread->cpu); @@ -1919,7 +1916,7 @@ thread_exit(void) panic("thread_exit() called with interrupts disabled!\n"); // boost our priority to get this over with - thread->priority = thread->next_priority = B_URGENT_DISPLAY_PRIORITY; + thread->priority = B_URGENT_DISPLAY_PRIORITY; if (team != kernelTeam) { // Cancel previously installed alarm timer, if any. Hold the scheduler @@ -2730,7 +2727,7 @@ thread_init(kernel_args *args) gCPU[i].running_thread = thread; thread->team = team_get_kernel_team(); - thread->priority = thread->next_priority = B_IDLE_PRIORITY; + thread->priority = B_IDLE_PRIORITY; thread->state = B_THREAD_RUNNING; thread->next_state = B_THREAD_READY; sprintf(name, "idle thread %" B_PRIu32 " kstack", i + 1); @@ -3217,7 +3214,7 @@ set_thread_priority(thread_id id, int32 priority) // It's ourself, so we know we aren't in the run queue, and we can // manipulate our structure directly. oldPriority = thread->priority; - thread->priority = thread->next_priority = priority; + thread->priority = priority; } else { oldPriority = thread->priority; scheduler_set_thread_priority(thread, priority);