Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
5
rtthread新版内核rt_schedule疑问
发布于 2021-01-21 23:18:18 浏览:1409
订阅该版
 图片中画红线的两处没看懂啥意思,跟之前的内核有点不一样,没看明白
查看更多
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.4k
关于作者
恋人心
这家伙很懒,什么也没写!
提问
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-thred的stm32h723对应bsp包CubeMX添加其他外设报错
2
RT-Thread中的time溢出问题,时间戳溢出,解决方法
3
ART-PI使用env驱动ETH网卡,pc和板子可以ping通
4
SystemView线程名字不显示
5
只用网页也能跑RT-Smart 无门槛腾讯Cloud studio + smart-build快速构建
热门标签
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
I2C_IIC
UART
ESP8266
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
keil_MDK
ulog
SFUD
msh
C++_cpp
MicroPython
本月问答贡献
RTT_逍遥
9
个答案
2
次被采纳
三世执戟
8
个答案
1
次被采纳
KunYi
8
个答案
1
次被采纳
xiaorui
3
个答案
1
次被采纳
winfeng
2
个答案
1
次被采纳
本月文章贡献
catcatbing
2
篇文章
5
次点赞
swet123
1
篇文章
4
次点赞
Days
1
篇文章
4
次点赞
YZRD
1
篇文章
2
次点赞
阳光的掌控者
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部