Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
rt_thread_suspend应该允许挂起当前线程和其他线程
发布于 2023-12-25 18:46:13 浏览:730
订阅该版
目前在使用的是lts-v4.1.x分支的V4.1.1版本。 有2个任务A、B,B在特殊情况下需要将A任务挂起,于是便在B线程中年调用rt_thread_suspend(A_thread_id),竟发现断言错误,查看源码发现这里的断言只允许挂起自己,这么做的限制是什么呢? ```c /** * @brief This function will suspend the specified thread and change it to suspend state. * * @note This function ONLY can suspend current thread itself. * rt_thread_suspend(rt_thread_self()); * * Do not use the rt_thread_suspend to suspend other threads. You have no way of knowing what code a * thread is executing when you suspend it. If you suspend a thread while sharing a resouce with * other threads and occupying this resouce, starvation can occur very easily. * * @param thread is the thread to be suspended. * * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_suspend(rt_thread_t thread) { rt_base_t stat; rt_base_t level; /* parameter check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); RT_ASSERT(thread == rt_thread_self()); ``` 从论坛中查看到的资料,早期的rt-thread是只允许挂起其他线程,不允许挂起自己。 
查看更多
3
个回答
默认排序
按发布时间排序
CrazyH
2023-12-25
这家伙很懒,什么也没写!
可以用其他方式挂起
出出啊
2023-12-25
恃人不如自恃,人之为己者不如己之自为也
我倒是对这个“特殊情况”挺感兴趣的,方便详细叙述一下吗?
a1012112796
2023-12-26
这家伙很懒,什么也没写!
不推荐使用 `rt_thread_suspend`.
撰写答案
登录
注册新账号
关注者
0
被浏览
730
关于作者
wzd5230
这家伙很懒,什么也没写!
提问
5
回答
1
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
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
【ci】【github】【bsp】RT-Thread仓库的CI自动编译测试
2
免费解锁MCU超能力!4月AIoT实战培训三城巡演
3
rt-thread主仓 BSP瘦身指南
4
Studio环境下ST M7系列USB主机(CherryUSB)配置及踩坑
5
RTT串口查找函数使用过程中遇到的问题。
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
rt-smart
RTC
FAL
I2C_IIC
cubemx
ESP8266
WIZnet_W5500
UART
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
GD32
定时器
ADC
flashDB
编译报错
socket
中断
rt_mq_消息队列_msg_queue
keil_MDK
Debug
SFUD
ulog
msh
C++_cpp
at_device
本月问答贡献
RTT_逍遥
4
个答案
2
次被采纳
聚散无由
3
个答案
2
次被采纳
踩姑娘的小蘑菇
4
个答案
1
次被采纳
a1012112796
3
个答案
1
次被采纳
YZRD
2
个答案
1
次被采纳
本月文章贡献
出出啊
1
篇文章
2
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
1
次点赞
crystal266
2
篇文章
1
次点赞
whj467467222
2
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部