用官网提供的EVT文件中的rtthread样版工程创建线程后,线程一直处于就绪态,不能运行打印出。
#include "ch32l103.h" #include #include #include "drivers/pin.h" #include #include #define DBG_TAG "main" rt_thread_t th1_ptr = NULL; struct rt_thread th2 ; rt_uint8_t th2_stack[512] = {0}; void th1_entry(void *parameter) { int i = 0; for(i = 0; i < 5 ; i++){ rt_kprintf("th1 running...\n"); rt_thread_mdelay(1000); } } void th2_entry(void *parameter) { int i = 0; for(i = 0; i < 5 ; i++) { rt_kprintf("th2 running...\n"); rt_thread_mdelay(1000); } } void scheduler_hook(struct rt_thread *from, struct rt_thread *to) { rt_kprintf("from:%s ---> to:%s\n",from->name,to->name); } int main(void) { int ret = 0; // rt_scheduler_sethook(scheduler_hook); th1_ptr = rt_thread_create("th1_demo",th1_entry,NULL,1024,20,5); if(th1_ptr == RT_NULL){ LOG_E("rt_thread_create failed...\n"); return -RT_ENOMEM; } LOG_D("rt_thread_create successed ...\n"); rt_thread_startup(th1_ptr); ret = rt_thread_init(&th2, "th2_demo", th2_entry, NULL, th2_stack, \ sizeof(th2_stack), 19, 5); if(ret < 0){ LOG_E("rt_thread_init failed...\n"); return ret; } LOG_D("rt_thread_init successed ...\n"); rt_thread_startup(&th2); }
热门产品 :
CH182: 以太网PHY收发器芯片