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;
|
||||||
|
|
|
@ -45,21 +45,21 @@ int thread_priority_init()
|
||||||
rt_err_t result;
|
rt_err_t result;
|
||||||
|
|
||||||
result = rt_thread_init(&thread1,
|
result = rt_thread_init(&thread1,
|
||||||
"t1",
|
"t1",
|
||||||
thread1_entry, RT_NULL,
|
thread1_entry, RT_NULL,
|
||||||
&thread1_stack[0], sizeof(thread1_stack),
|
&thread1_stack[0], sizeof(thread1_stack),
|
||||||
THREAD_PRIORITY - 1, THREAD_TIMESLICE);
|
THREAD_PRIORITY - 1, THREAD_TIMESLICE);
|
||||||
|
|
||||||
if (result == RT_EOK)
|
if (result == RT_EOK)
|
||||||
rt_thread_startup(&thread1);
|
rt_thread_startup(&thread1);
|
||||||
else
|
else
|
||||||
tc_stat(TC_STAT_FAILED);
|
tc_stat(TC_STAT_FAILED);
|
||||||
|
|
||||||
rt_thread_init(&thread2,
|
rt_thread_init(&thread2,
|
||||||
"t2",
|
"t2",
|
||||||
thread2_entry, RT_NULL,
|
thread2_entry, RT_NULL,
|
||||||
&thread2_stack[0], sizeof(thread2_stack),
|
&thread2_stack[0], sizeof(thread2_stack),
|
||||||
THREAD_PRIORITY + 1, THREAD_TIMESLICE);
|
THREAD_PRIORITY + 1, THREAD_TIMESLICE);
|
||||||
|
|
||||||
if (result == RT_EOK)
|
if (result == RT_EOK)
|
||||||
rt_thread_startup(&thread2);
|
rt_thread_startup(&thread2);
|
||||||
|
|
Loading…
Reference in New Issue