summaryrefslogtreecommitdiff
path: root/examples/kernel/thread_resume.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-12-19 07:08:06 +0000
committer[email protected] <[email protected]>2011-12-19 07:08:06 +0000
commitd28cdf68d923b355d144029f6aeb0aa405f3ab3f (patch)
treec7add4950886cbe726a0f43b914712fc48d0c1a4 /examples/kernel/thread_resume.c
parent212d828d3ff4dd0f57e2d2a54a9096f00eb88535 (diff)
update testcase for kernel.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1849 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/kernel/thread_resume.c')
-rw-r--r--examples/kernel/thread_resume.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/examples/kernel/thread_resume.c b/examples/kernel/thread_resume.c
index 23dfcdc132..e0ed6fa5f7 100644
--- a/examples/kernel/thread_resume.c
+++ b/examples/kernel/thread_resume.c
@@ -25,6 +25,17 @@ static void thread1_entry(void* parameter)
/* 当线程1被唤醒时 */
rt_kprintf("thread1 resumed\n");
}
+static void thread_cleanup(rt_thread_t tid)
+{
+ if (tid == tid1)
+ {
+ tid1 = RT_NULL;
+ }
+ if (tid == tid2)
+ {
+ tid = RT_NULL;
+ }
+}
/* 线程2入口 */
static void thread2_entry(void* parameter)
@@ -34,6 +45,7 @@ static void thread2_entry(void* parameter)
/* 唤醒线程1 */
rt_thread_resume(tid1);
+ rt_kprintf("thread2: to resume thread1\n");
/* 延时10个OS Tick */
rt_thread_delay(10);
@@ -48,7 +60,10 @@ int thread_resume_init()
thread1_entry, RT_NULL, /* 线程入口是thread1_entry, 入口参数是RT_NULL */
THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
if (tid1 != RT_NULL)
+ {
+ tid1->cleanup = thread_cleanup;
rt_thread_startup(tid1);
+ }
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
@@ -57,7 +72,10 @@ int thread_resume_init()
thread2_entry, RT_NULL, /* 线程入口是thread2_entry, 入口参数是RT_NULL */
THREAD_STACK_SIZE, THREAD_PRIORITY - 1, THREAD_TIMESLICE);
if (tid2 != RT_NULL)
+ {
+ tid2->cleanup = thread_cleanup;
rt_thread_startup(tid2);
+ }
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
@@ -90,7 +108,7 @@ int _tc_thread_resume()
thread_resume_init();
/* 返回TestCase运行的最长时间 */
- return 100;
+ return 25;
}
/* 输出函数命令到finsh shell中 */
FINSH_FUNCTION_EXPORT(_tc_thread_resume, a thread resume example);