kernel: Clean up _unpend_thread() API
Almost everywhere this was called, it was immediately followed by
_abort_thread_timeout(), for obvious reasons. The only exceptions
were in timeout and k_timer expiration (unifying these two would be
another good cleanup), which are peripheral parts of the scheduler and
can plausibly use a more "internal" API.
So make the common case the default, and expose the old behavior as
_unpend_thread_no_timeout(). (Along with identical changes for
_unpend_first_thread) Saves code bytes and simplifies scheduler
surface area for future synchronization work.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
diff --git a/kernel/sched.c b/kernel/sched.c
index 41f3012..3c5af4b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -230,6 +230,31 @@
#endif
}
+void _unpend_thread_no_timeout(struct k_thread *thread)
+{
+ __ASSERT(thread->base.thread_state & _THREAD_PENDING, "");
+
+ sys_dlist_remove(&thread->base.k_q_node);
+ _mark_thread_as_not_pending(thread);
+}
+
+void _unpend_thread(struct k_thread *thread)
+{
+ _unpend_thread_no_timeout(thread);
+ _abort_thread_timeout(thread);
+}
+
+struct k_thread *_unpend_first_thread(_wait_q_t *wait_q)
+{
+ struct k_thread *t = _unpend1_no_timeout(wait_q);
+
+ if (t) {
+ _abort_thread_timeout(t);
+ }
+
+ return t;
+}
+
/* Block the current thread and swap to the next. Releases the
* irq_lock, does a _Swap and returns the return value set at wakeup
* time