summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorBenjamin Walsh <benjamin.walsh@windriver.com>2016-10-05 17:16:01 -0400
committerBenjamin Walsh <benjamin.walsh@windriver.com>2016-10-10 21:27:37 +0000
commit055262c159ebed4f55ec4646e890159c4489fe1c (patch)
tree9f8993406b0131682db154c4f0de9f312b4a0ea9 /kernel
parent601b354ffefeab296d71df9fba9e2bc1e8c1580a (diff)
unified: remaining timeout cleanup
Rename remaining functions to fit with kernel naming convention for internal interfaces. Use struct k_thread instead of struct tcs. Change-Id: I28cd7f6f4d7ddaeb825c8d2999242d8d2dd93f31 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/unified/idle.c2
-rw-r--r--kernel/unified/include/timeout_q.h88
-rw-r--r--kernel/unified/include/wait_q.h6
-rw-r--r--kernel/unified/sem.c2
-rw-r--r--kernel/unified/sys_clock.c2
-rw-r--r--kernel/unified/timer.c2
-rw-r--r--kernel/unified/work_q.c2
7 files changed, 49 insertions, 55 deletions
diff --git a/kernel/unified/idle.c b/kernel/unified/idle.c
index d4a733754..3e70c07a1 100644
--- a/kernel/unified/idle.c
+++ b/kernel/unified/idle.c
@@ -132,7 +132,7 @@ void idle(void *unused1, void *unused2, void *unused3)
ARG_UNUSED(unused3);
for (;;) {
- _sys_power_save_idle(_timeout_get_next_expiry());
+ _sys_power_save_idle(_get_next_timeout_expiry());
k_yield();
}
diff --git a/kernel/unified/include/timeout_q.h b/kernel/unified/include/timeout_q.h
index 5f83facaa..e99464159 100644
--- a/kernel/unified/include/timeout_q.h
+++ b/kernel/unified/include/timeout_q.h
@@ -30,9 +30,9 @@ extern "C" {
#endif
#if defined(CONFIG_NANO_TIMEOUTS)
-/* initialize the nano timeouts part of TCS when enabled in the kernel */
+/* initialize the nano timeouts part of k_thread when enabled in the kernel */
-static inline void _timeout_init(struct _timeout *t, _timeout_func_t func)
+static inline void _init_timeout(struct _timeout *t, _timeout_func_t func)
{
/*
* Must be initialized here and when dequeueing a timeout so that code
@@ -48,10 +48,10 @@ static inline void _timeout_init(struct _timeout *t, _timeout_func_t func)
t->wait_q = NULL;
/*
- * Must be initialized here, so the _timeout_handle_one_timeout()
+ * Must be initialized here, so the _handle_one_timeout()
* routine can check if there is a fiber waiting on this timeout
*/
- t->tcs = NULL;
+ t->thread = NULL;
/*
* Function must be initialized before being potentially called.
@@ -61,36 +61,27 @@ static inline void _timeout_init(struct _timeout *t, _timeout_func_t func)
/*
* These are initialized when enqueing on the timeout queue:
*
- * tcs->timeout.node.next
- * tcs->timeout.node.prev
+ * thread->timeout.node.next
+ * thread->timeout.node.prev
*/
}
-static inline void _timeout_tcs_init(struct tcs *tcs)
+static inline void _init_thread_timeout(struct k_thread *thread)
{
- _timeout_init(&tcs->timeout, NULL);
+ _init_timeout(&thread->timeout, NULL);
}
/*
* XXX - backwards compatibility until the arch part is updated to call
- * _timeout_tcs_init()
+ * _init_thread_timeout()
*/
static inline void _nano_timeout_tcs_init(struct tcs *tcs)
{
- _timeout_tcs_init(tcs);
+ _init_thread_timeout(tcs);
}
-/**
- * @brief Remove the thread from nanokernel object wait queue
- *
- * If a thread waits on a nanokernel object with timeout,
- * remove the thread from the wait queue
- *
- * @param tcs Waiting thread
- * @param t nano timer
- *
- * @return N/A
- */
+/* remove a thread timing out from kernel object's wait queue */
+
static inline void _unpend_thread_timing_out(struct k_thread *thread,
struct _timeout *timeout_obj)
{
@@ -101,27 +92,29 @@ static inline void _unpend_thread_timing_out(struct k_thread *thread,
}
#else
-#define _unpend_thread_timing_out(tcs, timeout_obj) do { } while (0)
+#define _unpend_thread_timing_out(thread, timeout_obj) do { } while (0)
#endif /* CONFIG_NANO_TIMEOUTS */
/*
* Handle one expired timeout.
- * This removes the fiber from the timeout queue head, and also removes it
- * from the wait queue it is on if waiting for an object. In that case, it
- * also sets the return value to 0/NULL.
+ *
+ * This removes the thread from the timeout queue head, and also removes it
+ * from the wait queue it is on if waiting for an object. In that case,
+ * the return value is kept as -EAGAIN, set previously in _Swap().
+ *
+ * Must be called with interrupts locked.
*/
-/* must be called with interrupts locked */
-static inline struct _timeout *_timeout_handle_one_timeout(
+static inline struct _timeout *_handle_one_timeout(
sys_dlist_t *timeout_q)
{
struct _timeout *t = (void *)sys_dlist_get(timeout_q);
- struct tcs *tcs = t->tcs;
+ struct k_thread *thread = t->thread;
K_DEBUG("timeout %p\n", t);
- if (tcs != NULL) {
- _unpend_thread_timing_out(tcs, t);
- _ready_thread(tcs);
+ if (thread != NULL) {
+ _unpend_thread_timing_out(thread, t);
+ _ready_thread(thread);
} else if (t->func) {
t->func(t);
}
@@ -137,27 +130,24 @@ static inline struct _timeout *_timeout_handle_one_timeout(
return (struct _timeout *)sys_dlist_peek_head(timeout_q);
}
-/* loop over all expired timeouts and handle them one by one */
-/* must be called with interrupts locked */
-static inline void _timeout_handle_timeouts(void)
+/*
+ * Loop over all expired timeouts and handle them one by one.
+ * Must be called with interrupts locked.
+ */
+
+static inline void _handle_timeouts(void)
{
sys_dlist_t *timeout_q = &_nanokernel.timeout_q;
struct _timeout *next;
next = (struct _timeout *)sys_dlist_peek_head(timeout_q);
while (next && next->delta_ticks_from_prev == 0) {
- next = _timeout_handle_one_timeout(timeout_q);
+ next = _handle_one_timeout(timeout_q);
}
}
-/**
- *
- * @brief abort a timeout
- *
- * @param t Timeout to abort
- *
- * @return 0 in success and -1 if the timer has expired
- */
+/* returns 0 in success and -1 if the timer has expired */
+
static inline int _abort_timeout(struct _timeout *t)
{
sys_dlist_t *timeout_q = &_nanokernel.timeout_q;
@@ -195,7 +185,8 @@ static inline int _abort_thread_timeout(struct k_thread *thread)
* the timeout of the insert point to update its delta queue value, since the
* current timeout will be inserted before it.
*/
-static int _timeout_insert_point_test(sys_dnode_t *test, void *timeout)
+
+static int _is_timeout_insert_point(sys_dnode_t *test, void *timeout)
{
struct _timeout *t = (void *)test;
int32_t *timeout_to_insert = timeout;
@@ -214,6 +205,7 @@ static int _timeout_insert_point_test(sys_dnode_t *test, void *timeout)
*
* Cannot handle timeout == 0 and timeout == K_FOREVER.
*/
+
static inline void _add_timeout(struct k_thread *thread,
struct _timeout *timeout_obj,
_wait_q_t *wait_q, int32_t timeout)
@@ -233,11 +225,11 @@ static inline void _add_timeout(struct k_thread *thread,
K_DEBUG("timeout %p before: next: %p, prev: %p\n",
timeout_obj, timeout_obj->node.next, timeout_obj->node.prev);
- timeout_obj->tcs = thread;
+ timeout_obj->thread = thread;
timeout_obj->delta_ticks_from_prev = timeout;
timeout_obj->wait_q = (sys_dlist_t *)wait_q;
sys_dlist_insert_at(timeout_q, (void *)timeout_obj,
- _timeout_insert_point_test,
+ _is_timeout_insert_point,
&timeout_obj->delta_ticks_from_prev);
K_DEBUG("timeout_q %p after: head: %p, tail: %p\n",
@@ -254,6 +246,7 @@ static inline void _add_timeout(struct k_thread *thread,
*
* Cannot handle timeout == 0 and timeout == K_FOREVER.
*/
+
static inline void _add_thread_timeout(struct k_thread *thread,
_wait_q_t *wait_q, int32_t timeout)
{
@@ -261,7 +254,8 @@ static inline void _add_thread_timeout(struct k_thread *thread,
}
/* find the closest deadline in the timeout queue */
-static inline int32_t _timeout_get_next_expiry(void)
+
+static inline int32_t _get_next_timeout_expiry(void)
{
struct _timeout *t = (struct _timeout *)
sys_dlist_peek_head(&_timeout_q);
diff --git a/kernel/unified/include/wait_q.h b/kernel/unified/include/wait_q.h
index 3c0f0940e..eceda90d5 100644
--- a/kernel/unified/include/wait_q.h
+++ b/kernel/unified/include/wait_q.h
@@ -35,14 +35,14 @@ extern "C" {
#elif defined(CONFIG_NANO_TIMERS)
#include <timeout_q.h>
- #define _timeout_tcs_init(tcs) do { } while ((0))
+ #define _init_thread_timeout(tcs) do { } while ((0))
#define _abort_thread_timeout(tcs) do { } while ((0))
#define _add_thread_timeout(thread, pq, ticks) do { } while (0)
#else
- #define _timeout_tcs_init(tcs) do { } while ((0))
+ #define _init_thread_timeout(tcs) do { } while ((0))
#define _abort_thread_timeout(tcs) do { } while ((0))
- #define _timeout_get_next_expiry() (K_FOREVER)
+ #define _get_next_timeout_expiry() (K_FOREVER)
#define _add_thread_timeout(thread, pq, ticks) do { } while (0)
#endif
diff --git a/kernel/unified/sem.c b/kernel/unified/sem.c
index 23c9d0a05..681b67e3e 100644
--- a/kernel/unified/sem.c
+++ b/kernel/unified/sem.c
@@ -99,7 +99,7 @@ int k_sem_group_take(struct k_sem *sem_array[], struct k_sem **sem,
wait_objects[i].dummy.flags = K_DUMMY;
wait_objects[i].dummy.prio = priority;
- _timeout_tcs_init((struct k_thread *) &wait_objects[i].dummy);
+ _init_thread_timeout((struct k_thread *)&wait_objects[i].dummy);
sys_dlist_append(&list, &wait_objects[i].desc.semg_node);
wait_objects[i].desc.thread = _current;
diff --git a/kernel/unified/sys_clock.c b/kernel/unified/sys_clock.c
index dbd824fc2..6c18a965d 100644
--- a/kernel/unified/sys_clock.c
+++ b/kernel/unified/sys_clock.c
@@ -186,7 +186,7 @@ static inline void handle_expired_timeouts(int32_t ticks)
if (head) {
head->delta_ticks_from_prev -= ticks;
- _timeout_handle_timeouts();
+ _handle_timeouts();
}
}
#else
diff --git a/kernel/unified/timer.c b/kernel/unified/timer.c
index cccc244eb..c04de7454 100644
--- a/kernel/unified/timer.c
+++ b/kernel/unified/timer.c
@@ -75,7 +75,7 @@ void k_timer_init(struct k_timer *timer, void *data)
timer->user_data_internal = data;
timer->period = 0;
sys_dlist_init(&timer->wait_q);
- _timeout_init(&timer->timeout, timer_expiration_handler);
+ _init_timeout(&timer->timeout, timer_expiration_handler);
SYS_TRACING_OBJ_INIT(micro_timer, timer);
}
diff --git a/kernel/unified/work_q.c b/kernel/unified/work_q.c
index 9b495eeea..6bd3c3e00 100644
--- a/kernel/unified/work_q.c
+++ b/kernel/unified/work_q.c
@@ -75,7 +75,7 @@ static void work_timeout(struct _timeout *t)
void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
{
k_work_init(&work->work, handler);
- _timeout_init(&work->timeout, work_timeout);
+ _init_timeout(&work->timeout, work_timeout);
work->work_q = NULL;
}