Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
IPC
信号量_semaphore
我自己添加一个释放多个信号量的函数,会不会对系统有影响
发布于 2022-03-19 09:31:58 浏览:790
订阅该版
照葫芦画瓢的,值改了信号量添加的个数 ```c /** * @brief This function releases multiple semaphores. If there is a pending thread on the semaphore, it will be restored. * 此函数将释放多个信号量。如果信号量上有挂起的线程,它将被恢复。 * @note 如果此信号量上有挂起的线程,则此信号量对象列表中的第一个线程 *将恢复,并将执行线程调度(rt_调度)。 *如果此信号量上没有挂起线程,则此信号量的计数值sem->value将增加num。 * * @param sem is a pointer to a semaphore object. * @param num is a pointer to a rt_uint32_t.一次释放信号量的个数 * @return Return the operation status. When the return value is RT_EOK, the operation is successful. * If the return value is any other values, it means that the semaphore release failed. */ rt_err_t rt_sem_release_num(rt_sem_t sem,rt_uint32_t num) { register rt_base_t temp; register rt_bool_t need_schedule; /* parameter check */ RT_ASSERT(sem != RT_NULL); RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore); RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(sem->parent.parent))); need_schedule = RT_FALSE; /* disable interrupt */ temp = rt_hw_interrupt_disable(); RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n", rt_thread_self()->name, ((struct rt_object *)sem)->name, sem->value)); if (!rt_list_isempty(&sem->parent.suspend_thread)) { /* resume the suspended thread */ _ipc_list_resume(&(sem->parent.suspend_thread)); need_schedule = RT_TRUE; } else { if(sem->value < RT_SEM_VALUE_MAX) { sem->value +=num; /* increase value */ } else { rt_hw_interrupt_enable(temp); /* enable interrupt */ return -RT_EFULL; /* value overflowed */ } } /* enable interrupt */ rt_hw_interrupt_enable(temp); /* resume a thread, re-schedule */ if (need_schedule == RT_TRUE) rt_schedule(); return RT_EOK; } RTM_EXPORT(rt_sem_release_num); ```
查看更多
aozima
2022-03-19
调网络不抓包,调I2C等时序不上逻辑分析仪,就像电工不用万用表!多用整理的好的文字,比截图更省流量,还能在整理过程中思考。
感觉不如`while(num--)rt_sem_release();`来得简单
1
个回答
默认排序
按发布时间排序
撰写答案
登录
注册新账号
关注者
0
被浏览
790
关于作者
ZWH
这个人很勤快,没空留下点什么
提问
39
回答
149
被采纳
3
关注TA
发私信
相关问题
1
怎样可以将信号量复位为初始值
2
rt_sem_take 引起段错误
3
生产者消费者中是否可以使用一个事件集来代替多个二值信号量?
4
看RTT文档,不太懂有关信号量的死锁问题
5
这样使用UART接收一帧数据的方法是否可行
6
一对多线程间通信的问题
7
动态内存堆 保护全局变量lfree,为什么用信号量而不是互斥信号量
8
二值信号量的使用问题
9
USART1_IRQHandler串口中断接收问题
10
开发文档semaphore_sample.c有问题
推荐文章
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
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部