summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-18 20:24:55 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-18 20:28:04 +0200
commit7900da9667b2d0b052b63b0acf3cd85846935e98 (patch)
treecad86552807965a69f0a5fa32033e1d88ff4cb32 /Kernel
parent64a4f3df6978b3cf71737b897385576ee2afb4bd (diff)
downloadserenity-7900da9667b2d0b052b63b0acf3cd85846935e98.zip
Kernel: Make sure we never put the colonel thread in the runnable list.
This would cause it to get scheduled unnecessarily.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Scheduler.cpp3
-rw-r--r--Kernel/Thread.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index b7be97a008..4f6b55e048 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -232,6 +232,9 @@ bool Scheduler::pick_next()
}
#endif
+ if (g_runnable_threads->is_empty())
+ return context_switch(s_colonel_process->main_thread());
+
auto* previous_head = g_runnable_threads->head();
for (;;) {
// Move head to tail.
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 7d76c2663c..3060828a16 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -546,6 +546,7 @@ bool Thread::is_thread(void* ptr)
void Thread::set_thread_list(InlineLinkedList<Thread>* thread_list)
{
+ ASSERT(pid() != 0);
if (m_thread_list == thread_list)
return;
if (m_thread_list)
@@ -558,5 +559,6 @@ void Thread::set_thread_list(InlineLinkedList<Thread>* thread_list)
void Thread::set_state(State new_state)
{
m_state = new_state;
- set_thread_list(thread_list_for_state(new_state));
+ if (m_process.pid() != 0)
+ set_thread_list(thread_list_for_state(new_state));
}