完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
按照例程,在main函数中创建了两个线程
/******************************************************************************* local functions *******************************************************************************/ #define THREAD_PRIORITY 25 #define THREAD_STACK_SIZE 1024 #define THREAD_TIMESLICE 5 static rt_thread_t tid1 = RT_NULL; static void thread1_entry(void *parameter) { rt_uint32_t count = 0; while (1) { rt_kprintf("thread1 count: %d ", count ++); rt_thread_mdelay(500); } } ALIGN(RT_ALIGN_SIZE) static char thread2_stack[1024]; static struct rt_thread thread2; static void thread2_entry(void *param) { rt_uint32_t count = 0; for (count = 0; count < 10 ; count++) { rt_kprintf("thread2 count: %d ", count); } rt_kprintf("thread2 exit "); } int thread_sample(void) { tid1 = rt_thread_create("thread1", thread1_entry, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE); if (tid1 != RT_NULL) { rt_kprintf("FUNC[%s], LINE[%d] ", __FUNCTION__, __LINE__); rt_thread_startup(tid1); } rt_thread_init(&thread2, "thread2", thread2_entry, RT_NULL, &thread2_stack[0], sizeof(thread2_stack), THREAD_PRIORITY - 1, THREAD_TIMESLICE); rt_thread_startup(&thread2); return 0; } /******************************************************************************* public functions *******************************************************************************/ int main(void) { uint32_t ret = E_ERROR; uint32_t loop_flag = 1; rt_kprintf("Created time: %s[%s] ", __DATE__, __TIME__); thread_sample(); //while(1); while(1) { rt_thread_mdelay(1000); rt_kprintf("hello "); } if(loop_flag) { while(1) { reg32_write(TUBE_BASE_ADDR, 0x23); } } /* never reach here */ return 0; } 但是创建的两个线程好像没有运行 |
|
相关推荐
2个回答
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1004 浏览 0 评论
AI模型部署边缘设备的奇妙之旅:如何在边缘端部署OpenCV
3272 浏览 0 评论
tms320280021 adc采样波形,为什么adc采样频率上来波形就不好了?
1443 浏览 0 评论
2102 浏览 0 评论
1614 浏览 0 评论
75287 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 02:51 , Processed in 2.757903 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号