完善资料让更多小伙伴认识你,还能领取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个回答
|
|
|
|
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
999 浏览 0 评论
2781 浏览 0 评论
图腾柱PFC无法上升至400V,且电感电流为正弦波形,但是幅值极小
9368 浏览 0 评论
飞凌嵌入式ElfBoard-Vim编辑器之静态链接和动态链接
2895 浏览 0 评论
使用 LinkBoy 将程序导出为 C 语言代码并烧录至 Arduino ESP32 开发板
2300 浏览 1 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 20:59 , Processed in 0.704492 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1199