From c6c6b5ef74fa3af437c5a3df7ff16ee4f0f41093 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Wed, 18 Dec 2013 21:39:03 +0800 Subject: [PATCH] TC: semaphore_dynamic: code cleanup --- examples/kernel/semaphore_dynamic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/kernel/semaphore_dynamic.c b/examples/kernel/semaphore_dynamic.c index 7f2c2ffd42..579d9daa9a 100644 --- a/examples/kernel/semaphore_dynamic.c +++ b/examples/kernel/semaphore_dynamic.c @@ -90,13 +90,16 @@ static void _tc_cleanup() /* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */ rt_enter_critical(); + if (sem) + { + rt_sem_delete(sem); + sem = RT_NULL; + } + /* 删除线程 */ if (tid != RT_NULL && tid->stat != RT_THREAD_CLOSE) { rt_thread_delete(tid); - - /* 删除信号量 */ - rt_sem_delete(sem); } /* 调度器解锁 */