TC: more tolerate for tick in TC thread

This commit is contained in:
Grissiom 2013-12-21 13:18:09 +08:00
parent f7b1421880
commit f6bf69f233
3 changed files with 17 additions and 13 deletions

View File

@ -27,9 +27,13 @@ static void thread_entry(void* parameter)
result = rt_sem_take(&sem, 10);
if (result == -RT_ETIMEOUT)
{
/* 超时后判断是否刚好是10个OS Tick */
if (rt_tick_get() - tick != 10)
rt_tick_t new_tick = rt_tick_get();
/* 可以有两个 tick 的误差 */
if (new_tick - tick >= 12)
{
rt_kprintf("tick error to large: expect: 10, get %d\n",
new_tick - tick);
tc_done(TC_STAT_FAILED);
rt_sem_detach(&sem);
return;

View File

@ -14,7 +14,7 @@ static void thread_entry(void* parameter)
rt_kprintf("thread delay 10 tick\n");
tick = rt_tick_get();
rt_thread_delay(10);
if (rt_tick_get() - tick > 10)
if (rt_tick_get() - tick > 11)
{
tc_done(TC_STAT_FAILED);
return;
@ -23,7 +23,7 @@ static void thread_entry(void* parameter)
rt_kprintf("thread delay 15 tick\n");
tick = rt_tick_get();
rt_thread_delay(15);
if (rt_tick_get() - tick > 15)
if (rt_tick_get() - tick > 16)
{
tc_done(TC_STAT_FAILED);
return;