thread_static.c 946 字节
Newer Older
B
Bernard Xiong 已提交
1 2 3 4 5 6 7 8 9 10
#include <rtthread.h>
#include "tc_comm.h"

/*
 * This is an example for static thread
 */
static struct rt_thread thread;
static char thread_stack[THREAD_STACK_SIZE];
static void thread_entry(void* parameter)
{
G
Grissiom 已提交
11 12 13
    rt_kprintf("thread staticly inited ok\n");
    rt_thread_delay(10);
    rt_kprintf("thread exit\n");
B
Bernard Xiong 已提交
14

G
Grissiom 已提交
15
    tc_done(TC_STAT_PASSED);
B
Bernard Xiong 已提交
16 17 18 19
}

rt_err_t thread_static_init()
{
G
Grissiom 已提交
20
    rt_err_t result;
B
Bernard Xiong 已提交
21

G
Grissiom 已提交
22 23 24 25 26
    result = rt_thread_init(&thread,
        "test",
        thread_entry, RT_NULL,
        &thread_stack[0], sizeof(thread_stack),
        THREAD_PRIORITY, 10);
B
Bernard Xiong 已提交
27

G
Grissiom 已提交
28 29 30 31
    if (result == RT_EOK)
        rt_thread_startup(&thread);
    else
        tc_stat(TC_STAT_END | TC_STAT_FAILED);
B
Bernard Xiong 已提交
32

G
Grissiom 已提交
33
    return result;
B
Bernard Xiong 已提交
34 35 36 37 38
}

#ifdef RT_USING_TC
int _tc_thread_static()
{
G
Grissiom 已提交
39
    thread_static_init();
B
Bernard Xiong 已提交
40

G
Grissiom 已提交
41
    return 20;
B
Bernard Xiong 已提交
42 43 44 45 46
}
FINSH_FUNCTION_EXPORT(_tc_thread_static, a static thread test);
#else
int rt_application_init()
{
G
Grissiom 已提交
47
    thread_static_init();
B
Bernard Xiong 已提交
48

G
Grissiom 已提交
49
    return 0;
B
Bernard Xiong 已提交
50 51 52
}
#endif