From a8ba93e97cee8b5ca562834491fac7c978c116f7 Mon Sep 17 00:00:00 2001 From: wuyangyong Date: Fri, 18 Mar 2011 03:01:02 +0000 Subject: [PATCH] update fs_test.c git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1335 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/test/fs_test.c | 77 +++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/examples/test/fs_test.c b/examples/test/fs_test.c index ab0b64ce14..bc18a196f1 100644 --- a/examples/test/fs_test.c +++ b/examples/test/fs_test.c @@ -11,18 +11,18 @@ * Date Author Notes * 2011-01-02 aozima the first version. * 2011-03-17 aozima fix some bug. + * 2011-03-18 aozima to dynamic thread. */ #include #include static rt_uint32_t stop_flag = 0; +static rt_thread_t fsrw1_thread = RT_NULL; +static rt_thread_t fsrw2_thread = RT_NULL; #define fsrw1_fn "/test1.dat" #define fsrw1_data_len 120 /* Less than 256 */ - -static struct rt_thread fsrw1_thread; -static rt_uint32_t fsrw1_stack[1024/sizeof(rt_uint32_t)]; static void fsrw1_thread_entry(void* parameter) { int fd; @@ -40,6 +40,8 @@ static void fsrw1_thread_entry(void* parameter) if( stop_flag ) { rt_kprintf("thread fsrw2 error,thread fsrw1 quit!\r\n"); + fsrw1_thread = RT_NULL; + stop_flag = 0; return; } @@ -49,6 +51,7 @@ static void fsrw1_thread_entry(void* parameter) { rt_kprintf("fsrw1 open file for write failed\n"); stop_flag = 1; + fsrw1_thread = RT_NULL; return; } @@ -67,6 +70,7 @@ static void fsrw1_thread_entry(void* parameter) { rt_kprintf("fsrw1 write data failed\n"); close(fd); + fsrw1_thread = RT_NULL; stop_flag = 1; return; } @@ -83,6 +87,7 @@ static void fsrw1_thread_entry(void* parameter) { rt_kprintf("fsrw1 open file for read failed\n"); stop_flag = 1; + fsrw1_thread = RT_NULL; return; } @@ -98,6 +103,7 @@ static void fsrw1_thread_entry(void* parameter) rt_kprintf("fsrw1 read file failed\r\n"); close(fd); stop_flag = 1; + fsrw1_thread = RT_NULL; return; } for(i=0; i