From 0eaf2098b86ceef04b60fdd5407ccd9a3206def0 Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Sat, 22 May 2010 23:26:08 +0000 Subject: fix the timer check bug. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@730 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- src/clock.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/clock.c') diff --git a/src/clock.c b/src/clock.c index 4f785dd5b9..6ca918d1f8 100644 --- a/src/clock.c +++ b/src/clock.c @@ -11,8 +11,9 @@ * Date Author Notes * 2006-03-12 Bernard first version * 2006-05-27 Bernard add support for same priority thread schedule - * 2006-08-10 Bernard remove the last rt_schedule in rt_tick_increase + * 2006-08-10 Bernard remove the last rt_schedule in rt_tick_increase * 2010-03-08 Bernard remove rt_passed_second + * 2010-05-20 Bernard fix the tick exceeds the maximum limits */ #include @@ -20,6 +21,7 @@ static rt_tick_t rt_tick; extern void rt_timer_check(void); +extern void rt_timer_switch(void); /** * This function will init system tick and set it to zero. @@ -57,10 +59,14 @@ void rt_tick_increase() struct rt_thread* thread; /* increase the global tick */ - ++ rt_tick; + if (rt_tick == RT_TICK_MAX) + { + /* switch to long timer list */ + rt_timer_switch(); - /* check timer */ - rt_timer_check(); + rt_tick = 0; + } + else ++ rt_tick; /* check time slice */ thread = rt_thread_self(); @@ -74,6 +80,9 @@ void rt_tick_increase() /* yield */ rt_thread_yield(); } + + /* check timer */ + rt_timer_check(); } /** -- cgit v1.3.1