Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
pipe
select
10
select不返回问题,昨天未描述清楚
发布于 2021-05-26 08:47:31 浏览:1471
订阅该版
项目中使用pipe通道,两个fd,一个线程读pipe的数据,一个线程写pipe的数据,优先级读的高一些,写的线程100ms写一次,读的线程判了select,设置了超时3s退出(系统配置的是硬件时钟,软时钟没启动),系统运行一段时间后发现读线程的select不返回了,类似于在select里进入了死循环,看了内核的select.c poll.c pipe.c timer.c的代码,去官网搜了已知bug,这几个文件我更新到了最新,但是现象依然存在。现象出现时,我查看了这两线程都处于ready状态,但是运行计数都不在增加,现在就是没有排查思路了,麻烦大神指点一下可能出问题的地方,万分感谢。 自己有几个疑问:1.如果是超时出了问题,那么线程应该处于挂起才对,在poll_wait_out函数中设置定时器时先挂起线程。 ```c static int poll_wait_timeout(struct rt_poll_table *pt, int msec) { rt_int32_t timeout; int ret = 0; struct rt_thread *thread; rt_base_t level; thread = pt->polling_thread; timeout = rt_tick_from_millisecond(msec); level = rt_hw_interrupt_disable(); if (timeout != 0 && !pt->triggered) { rt_thread_suspend(thread); if (timeout > 0) { rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout); rt_timer_start(&(thread->thread_timer)); } rt_hw_interrupt_enable(level); rt_schedule(); level = rt_hw_interrupt_disable(); } ret = !pt->triggered; rt_hw_interrupt_enable(level); return ret; } ``` 2.在_poll_add函数中 ```c static void _poll_add(rt_wqueue_t *wq, rt_pollreq_t *req) { struct rt_poll_table *pt; struct rt_poll_node *node; node = (struct rt_poll_node *)rt_malloc(sizeof(struct rt_poll_node)); if (node == RT_NULL) return; pt = rt_container_of(req, struct rt_poll_table, req); node->wqn.key = req->_key; rt_list_init(&(node->wqn.list)); node->wqn.polling_thread = pt->polling_thread; node->wqn.wakeup = __wqueue_pollwake; node->next = pt->nodes; node->pt = pt; pt->nodes = node; rt_wqueue_add(wq, &node->wqn); } ``` 使用rt_malloc分配了堆内存,但是我去查看并未发现有释放堆的操作 ```c void rt_wqueue_wakeup(rt_wqueue_t *queue, void *key) { rt_base_t level; register int need_schedule = 0; rt_list_t *queue_list; struct rt_list_node *node; struct rt_wqueue_node *entry; queue_list = &(queue->waiting_list); level = rt_hw_interrupt_disable(); /* set wakeup flag in the queue */ queue->flag = RT_WQ_FLAG_WAKEUP; if (!(rt_list_isempty(queue_list))) { for (node = queue_list->next; node != queue_list; node = node->next) { entry = rt_list_entry(node, struct rt_wqueue_node, list); if (entry->wakeup(entry, key) == 0) { rt_thread_resume(entry->polling_thread); need_schedule = 1; rt_wqueue_remove(entry); break; } } } rt_hw_interrupt_enable(level); if (need_schedule) rt_schedule(); } ``` ``` void rt_wqueue_remove(struct rt_wqueue_node *node) { rt_base_t level; level = rt_hw_interrupt_disable(); rt_list_remove(&(node->list)); rt_hw_interrupt_enable(level); } ``` ``` rt_inline void rt_list_remove(rt_list_t *n) { n->next->prev = n->prev; n->prev->next = n->next; n->next = n->prev = n; } ```
查看更多
2
个回答
默认排序
按发布时间排序
aozima
2022-09-30
调网络不抓包,调I2C等时序不上逻辑分析仪,就像电工不用万用表!多用整理的好的文字,比截图更省流量,还能在整理过程中思考。
后续解决: - https://club.rt-thread.org/ask/question/2c940eeecafbff81.html - https://github.com/RT-Thread/rt-thread/pull/5740
flashman2002
2021-05-26
这家伙很懒,什么也没写!
系统死机也不见得是在select上,你需要追踪死机时的系统调用顺序。
撰写答案
登录
注册新账号
关注者
0
被浏览
1.5k
关于作者
NR1101
这家伙很懒,什么也没写!
提问
10
回答
6
被采纳
0
关注TA
发私信
相关问题
1
使用fifo通道读取数据select不返回
2
之前select死循环的问题查清楚了
3
pahomqtt 编译时提示 缺少pipe是什么情况?
4
pipe 发送超过16384长度,会被截断
5
paho-mqtt pipe和socket 同时发送会导致pipe数据丢失
6
接收数据不触发select
7
支持多个fd同时select,目前的rtt貌似不支持
8
非阻塞 socket
9
请问Kconfig中select 如何选择非bool值的config的值呢
10
tcpclient_select_sample 等待网络函数参数问题
推荐文章
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
【CFP】2025 RT-Thread全球技术大会演讲征集开始啦!
2
在 RT-Thread Studio 环境中为 ART-Pi 2 移植 CherryUSB(以 usb_device 为例)
3
嵌入式ARM RISCV toolchain工具 梳理arm-none-eabi-gcc
4
使用官方BOOT升级,看这一篇就够了?(以STM32F407VGT6为例)
5
可以使用MQTT连接AI大模型吗
热门标签
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
cubemx
ESP8266
WIZnet_W5500
UART
ota在线升级
BSP
PWM
flash
packages_软件包
freemodbus
潘多拉开发板_Pandora
ADC
GD32
定时器
flashDB
编译报错
keil_MDK
socket
中断
rt_mq_消息队列_msg_queue
Debug
ulog
SFUD
msh
C++_cpp
at_device
本月问答贡献
聚散无由
9
个答案
6
次被采纳
RTT_逍遥
7
个答案
2
次被采纳
a1012112796
5
个答案
2
次被采纳
加缪
2
个答案
2
次被采纳
踩姑娘的小蘑菇
9
个答案
1
次被采纳
本月文章贡献
wake_mirco
2
篇文章
7
次点赞
mushroom
1
篇文章
9
次点赞
张世争
1
篇文章
7
次点赞
RTT_逍遥
1
篇文章
5
次点赞
Jack_____
1
篇文章
5
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部