diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index 197d93ad..02d9c4cc 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -330,11 +330,13 @@ namespace Kernel { if (!node->blocked) return; - m_block_queue.remove_node(node); + if (node != m_current) + m_block_queue.remove_node(node); if (node->blocker) node->blocker->remove_blocked_thread(node); node->blocked = false; - m_run_queue.add_thread_to_back(node); + if (node != m_current) + m_run_queue.add_thread_to_back(node); } else { @@ -467,6 +469,9 @@ namespace Kernel break; if (thread_info.node == m_current || thread_info.queue == nullptr) continue; + // FIXME: allow load balancing with blocked threads, with this algorithm there is a race condition + if (thread_info.node->blocked) + continue; auto least_loaded_id = find_least_loaded_processor(); if (least_loaded_id == Processor::current_id())