Browse Source

TC: release the sem in cleanup

The sem that has been created should be deleted. The sem that has been
inited should be detached.
Grissiom 11 years ago
parent
commit
4434c87a71

+ 6 - 0
examples/kernel/semaphore_priority.c

@@ -100,6 +100,12 @@ static void _tc_cleanup()
 	rt_thread_delete(t2);
 	rt_thread_delete(worker);
 
+	if (sem)
+	{
+		rt_sem_delete(sem);
+		sem = RT_NULL;
+	}
+
 	if (t1_count > t2_count)
 		tc_done(TC_STAT_FAILED);
 	else

+ 4 - 0
examples/kernel/semaphore_producer_consumer.c

@@ -119,6 +119,10 @@ static void _tc_cleanup()
 	/* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */
 	rt_enter_critical();
 
+	rt_sem_detach(&sem_lock);
+	rt_sem_detach(&sem_empty);
+	rt_sem_detach(&sem_full);
+
 	/* 删除线程 */
 	if (producer_tid != RT_NULL && producer_tid->stat != RT_THREAD_CLOSE)
 		rt_thread_delete(producer_tid);