summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorGrissiom <[email protected]>2013-09-26 15:52:02 +0800
committerGrissiom <[email protected]>2013-10-12 22:48:29 +0800
commitd59aa279c37b7aba07385a3a2cb3057bce6c5fea (patch)
treef31c60b9e357c6c0f62485069ffad7fa52315868 /src/thread.c
parent83bb05419f7aba80f6a10a48f88a2838a356737a (diff)
kernel: use skip list to implement timer list
Skip list is a "random" data structure that in high possibilities it would get O(log(N)) time complexity in inserting while the old list get O(N). Forthermore, when set RT_TIMER_SKIP_LIST_LEVEL to 1, it will just the same as the old double linked list, both in time and space complexity. Benchmarks shows that when RT_TIMER_SKIP_LIST_LEVEL is 3, the average time of random insertion of new timer is about 2 times faster than the old timer when there are 100 timers and 3 times faster when there are 200 timers. However, it restores the deprecated funcion rt_system_timer_init. BSPs must invoke it upon system startup.
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/thread.c b/src/thread.c
index da77ace289..c2282f6ee6 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -61,8 +61,7 @@ static void rt_thread_exit(void)
thread->stat = RT_THREAD_CLOSE;
/* remove it from timer list */
- rt_list_remove(&(thread->thread_timer.list));
- rt_object_detach((rt_object_t)&(thread->thread_timer));
+ rt_timer_detach(&thread->thread_timer);
if ((rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) &&
thread->cleanup == RT_NULL)
@@ -613,11 +612,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
/* remove from suspend list */
rt_list_remove(&(thread->tlist));
- /* remove thread timer */
- rt_list_remove(&(thread->thread_timer.list));
-
- /* change timer state */
- thread->thread_timer.parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
+ rt_timer_stop(&thread->thread_timer);
/* enable interrupt */
rt_hw_interrupt_enable(temp);