Explorar o código

TC: semaphore_dynamic: code cleanup

Grissiom %!s(int64=11) %!d(string=hai) anos
pai
achega
c6c6b5ef74
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      examples/kernel/semaphore_dynamic.c

+ 6 - 3
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);
 	}
 
 	/* 调度器解锁 */