From bd696585719a96f8ee7010925e96566023101df0 Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Fri, 16 Sep 2016 10:08:52 -0400 Subject: [PATCH] unified: Add _is_next_thread_current() The routine _is_next_thread_current() checks if the current thread is still the highest priority thread that is ready to run. It is useful for determining if a thread must be swapped out when timeslicing is in effect. Change-Id: Ide7b89742a64f6082ca4c679a4b2fbd60792e30f Signed-off-by: Peter Mitsis --- kernel/unified/sched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/unified/sched.c b/kernel/unified/sched.c index 683197a420e..70ee798b617 100644 --- a/kernel/unified/sched.c +++ b/kernel/unified/sched.c @@ -178,6 +178,11 @@ int __must_switch_threads(void) return _is_prio_higher(_get_highest_ready_prio(), _current->prio); } +int _is_next_thread_current(void) +{ + return _get_next_ready_thread() == _current; +} + /* application API: change a thread's priority. Not callable from ISR */ void k_thread_priority_set(struct tcs *thread, int prio) {