summaryrefslogtreecommitdiff
path: root/examples/kernel
diff options
context:
space:
mode:
authorGrissiom <[email protected]>2013-12-18 20:52:55 +0800
committerGrissiom <[email protected]>2013-12-18 20:52:55 +0800
commite9e8e3f3cafbbd1287e4226b93b9ad5d40f211e3 (patch)
treea82177549a3f3a64900e01b2ce68c0aaa61f3bbd /examples/kernel
parentcb347f5af05be87d673ec7c53662eb5e61ed681d (diff)
TC: do not use rt_sem_trytake to clean the sem
There can be a race condition that the sem has alread been detached after we did the cleanup. Besides, there is a RT_IPC_CMD_RESET command in rt_sem_control which is more clear in setting the sem values.
Diffstat (limited to 'examples/kernel')
-rw-r--r--examples/kernel/tc_comm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/kernel/tc_comm.c b/examples/kernel/tc_comm.c
index 60d843171f..bf23d80550 100644
--- a/examples/kernel/tc_comm.c
+++ b/examples/kernel/tc_comm.c
@@ -40,6 +40,8 @@ void tc_thread_entry(void* parameter)
tick = index->func();
if (tick > 0)
{
+ /* Make sure we are going to be blocked. */
+ rt_sem_control(&_tc_sem, RT_IPC_CMD_RESET, 0);
rt_sem_take(&_tc_sem, tick * _tc_scale);
if (_tc_cleanup != RT_NULL)
@@ -49,8 +51,6 @@ void tc_thread_entry(void* parameter)
_tc_cleanup = RT_NULL;
}
- rt_sem_trytake(&_tc_sem);/* by nl1031 */
-
if (_tc_stat & TC_STAT_FAILED)
rt_kprintf("TestCase[%s] failed\n", _tc_current);
else