Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
5
rtthread新版内核rt_schedule疑问
发布于 2021-01-21 23:18:18 浏览:1120
订阅该版
![SharedScreenshot.jpg](https://oss-club.rt-thread.org/uploads/20210121/3b28e1142fc37244294c41eb22bb5688.jpg) 图片中画红线的两处没看懂啥意思,跟之前的内核有点不一样,没看明白
查看更多
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.1k
关于作者
恋人心
这家伙很懒,什么也没写!
提问
14
回答
25
被采纳
0
关注TA
发私信
相关问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
机器人操作系统 (ROS2) 和 RT-Thread 通信
4
国产MCU移植系列教程汇总,欢迎查看!
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
NXP MCXN947测评(二)ETH设备使用
2
【RA8D1-Vision Board】适配 LVGL V8
3
VISION BOARD 第二弹 基础工程配置和点亮一个LED灯
4
musb移植问题记录【设备注册3次挂起】
5
关于使用CherryUSB时候使用外挂的usb phy 芯片配置的一点注意事项
热门标签
RT-Thread Studio
串口
LWIP
Env
SPI
Bootloader
AT
ART-Pi
Hardfault
CAN总线
FinSH
USB
文件系统
RT-Thread
DMA
SCons
线程
RT-Thread Nano
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
ota在线升级
WIZnet_W5500
I2C_IIC
UART
flash
cubemx
packages_软件包
freemodbus
潘多拉开发板_Pandora
PWM
定时器
ADC
BSP
中断
keil_MDK
编译报错
socket
MicroPython
GD32
msh
Debug
ulog
SDIO总线
SFUD
rt_mq_消息队列_msg_queue
C++_cpp
本月问答贡献
xiaorui
7
个答案
3
次被采纳
sakumisu
4
个答案
3
次被采纳
三世执戟
31
个答案
1
次被采纳
梦笑真美
18
个答案
1
次被采纳
踩姑娘的小蘑菇
14
个答案
1
次被采纳
本月文章贡献
Z_Y
2
篇文章
5
次点赞
Alipay
2
篇文章
3
次点赞
2345vor
2
篇文章
1
次点赞
比特饼干
1
篇文章
6
次点赞
Vangaoven
1
篇文章
3
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部