TC: more tolerate for tick in TC thread
This commit is contained in:
parent
f7b1421880
commit
f6bf69f233
|
@ -27,9 +27,13 @@ static void thread_entry(void* parameter)
|
||||||
result = rt_sem_take(&sem, 10);
|
result = rt_sem_take(&sem, 10);
|
||||||
if (result == -RT_ETIMEOUT)
|
if (result == -RT_ETIMEOUT)
|
||||||
{
|
{
|
||||||
/* 超时后判断是否刚好是10个OS Tick */
|
rt_tick_t new_tick = rt_tick_get();
|
||||||
if (rt_tick_get() - tick != 10)
|
/* 可以有两个 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);
|
tc_done(TC_STAT_FAILED);
|
||||||
rt_sem_detach(&sem);
|
rt_sem_detach(&sem);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,7 +14,7 @@ static void thread_entry(void* parameter)
|
||||||
rt_kprintf("thread delay 10 tick\n");
|
rt_kprintf("thread delay 10 tick\n");
|
||||||
tick = rt_tick_get();
|
tick = rt_tick_get();
|
||||||
rt_thread_delay(10);
|
rt_thread_delay(10);
|
||||||
if (rt_tick_get() - tick > 10)
|
if (rt_tick_get() - tick > 11)
|
||||||
{
|
{
|
||||||
tc_done(TC_STAT_FAILED);
|
tc_done(TC_STAT_FAILED);
|
||||||
return;
|
return;
|
||||||
|
@ -23,7 +23,7 @@ static void thread_entry(void* parameter)
|
||||||
rt_kprintf("thread delay 15 tick\n");
|
rt_kprintf("thread delay 15 tick\n");
|
||||||
tick = rt_tick_get();
|
tick = rt_tick_get();
|
||||||
rt_thread_delay(15);
|
rt_thread_delay(15);
|
||||||
if (rt_tick_get() - tick > 15)
|
if (rt_tick_get() - tick > 16)
|
||||||
{
|
{
|
||||||
tc_done(TC_STAT_FAILED);
|
tc_done(TC_STAT_FAILED);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue