From 032ff97fbd8361146a37a3af6b6760db1d3c4afb Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 6 Oct 2008 23:00:17 +0000 Subject: [PATCH] When a thread times out on a locking primitive, reschedule only, if the timed out thread has a higher priority than the currently running one. Maybe we should even restrict this behavior to realtime threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27897 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/thread.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 2ed6d50cbd..979787c02a 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -2186,8 +2186,14 @@ thread_block_timeout(timer* timer) // easy. struct thread* thread = (struct thread*)timer->user_data; - if (thread_unblock_locked(thread, B_TIMED_OUT)) - return B_INVOKE_SCHEDULER; + if (thread_unblock_locked(thread, B_TIMED_OUT)) { + // We actually woke up the thread. If it has a higher priority than the + // currently running thread, we invoke the scheduler. + // TODO: Is this really such a good idea or should we do that only when + // the woken up thread has realtime priority? + if (thread->priority > thread_get_current_thread()->priority) + return B_INVOKE_SCHEDULER; + } return B_HANDLED_INTERRUPT; }