Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
5
rtthread新版内核rt_schedule疑问
发布于 2021-01-21 23:18:18 浏览:1451
订阅该版
 图片中画红线的两处没看懂啥意思,跟之前的内核有点不一样,没看明白
查看更多
whj467467222
认证专家
2021-01-22
开源,分享,交流,共同进步
请更多的使用 `MD` 格式排版出关键的代码。 ```c if (need_insert_from_thread) { rt_schedule_insert_thread(from_thread); } ``` 将 `from_thread` 插入到调度链表,如果没有异常则会设置线程状态为 `RT_THREAD_READY`, 这样`from_thread` 就从**运行态**切换到了**就绪态**,这样 `from_thread` 就暂停工作了。 ```c rt_schedule_remove_thread(to_thread); to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK); ``` 将 `to_thread` 移除调度链表,并设置为 **运行态**, 等待下一次进入 `rt_schedule` 的时候 `to_thread` 就是 `from_thread`, 就会插入到线程链表中。 这样操作之后在 `rt_schedule` 执行完毕之后,就会触发一次 `pend_sv`, 这样就完成了一次线程的切换。 如果帮助到你了,请点击采纳答案。
4
个回答
默认排序
按发布时间排序
恋人心
2021-01-21
这家伙很懒,什么也没写!
哪位大神看明白了帮忙解释一下呗
xiaotong_n
2021-04-27
这家伙很懒,什么也没写!
对于to_thread被移除,我理解: ``` if (to_thread != rt_current_thread) { /* if the destination thread is not the same as current thread */ rt_current_priority = (rt_uint8_t)highest_ready_priority; from_thread = rt_current_thread; rt_current_thread = to_thread; RT_OBJECT_HOOK_CALL(rt_scheduler_hook, (from_thread, to_thread)); if (need_insert_from_thread) { rt_schedule_insert_thread(from_thread); } rt_schedule_remove_thread(to_thread); to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK); ``` 这里应该是从就绪列表移除to_thread,这应该移除to_thread结点信息,而真正的to_thread内容在rt_current_thread里; 当下一次切换的时候,将 from_thread =rt_current_thread; rt_schedule_insert_thread(from_thread); 这样就是实现将“to_thread”由插入到列表中了。
rtt_newer
2023-09-05
这家伙很懒,什么也没写!
已解决!!
撰写答案
登录
注册新账号
关注者
0
被浏览
1.5k
关于作者
恋人心
这家伙很懒,什么也没写!
提问
15
回答
25
被采纳
0
关注TA
发私信
相关问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
基于RT-Thread的STM32开发第一讲——USART
2
pkgs --upgrade报错SSL未验证问题解决记录
3
CherryUSB STM32 glue 新增初始化
4
在LPC1114上移植 RT-Thread Nano 3.1.5
5
求助can通讯下怎末运用485
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
cubemx
I2C_IIC
UART
ESP8266
WIZnet_W5500
BSP
ota在线升级
PWM
flash
packages_软件包
freemodbus
潘多拉开发板_Pandora
ADC
GD32
定时器
flashDB
编译报错
keil_MDK
socket
中断
rt_mq_消息队列_msg_queue
Debug
ulog
SFUD
msh
C++_cpp
at_device
本月问答贡献
出出啊
1524
个答案
343
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
818
个答案
179
次被采纳
crystal266
555
个答案
162
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
3
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
10
次点赞
crystal266
2
篇文章
1
次点赞
whj467467222
2
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部