提交 ac0e10bb 编写于 作者: G Grissiom

TC: more tolerate on the timeout tick in semaphore_dynamic

With system that has RT_TICK_PER_SECOND is 1000, it's easy to get one
tick error.
上级 46f9280a
...@@ -25,9 +25,13 @@ static void thread_entry(void* parameter) ...@@ -25,9 +25,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_delete(sem); rt_sem_delete(sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册