当前位置:网站首页>Shared memory - shmget filling holes
Shared memory - shmget filling holes
2022-07-29 14:23:00 【A corner of peace, occupying the mountain as the king】
shmget设置的size值,不能大于最大值SHMMAXand is less than the minimum valueSHMMIN
且若是keyThe segment corresponding to the value already exists,Then use it latershmget的sizeThe value must be less than or equal to the original value function
Then I asked the programmer,He set20kB,个人是100kB,And his settings are to start at boot,So it was me who made the mistake every time,悲催!
/******************************************************************************
*函数名称:yg_init_mem_share
*功能描述: 初始化共享内存(Used to store map calibration data)
*全局影响:无
*输入:
*输出:无
*返回值:0:成功 -1:发送失败
* 做者 日期 内容
* Jimmy 2018-10-16 建立
*
******************************************************************************/
void yg_init_mem_share(int size)
{
key_t key;
//int size = 1024*1024; //1M内存大小
//1. 建立共享内存
if(-1 == (key = ftok("/", 4)))
{
bv_loge("ftok failed [%d:%s]!", errno, strerror(errno));
bv_error_handle("ftok failed [%d:%s]!", errno, strerror(errno));
return ;
}
bv_logd("key=%#x!", key);
SHM_ID = shmget(key, (size_t)size, IPC_CREAT|0644);
if(-1 == SHM_ID)
{
bv_loge("Init the shared memory[%dKB] failed [%d:%s]!",size/1024, errno, strerror(errno));
bv_error_handle("Init the shared memory[%dKB] failed [%d:%s]!",size/1024, errno, strerror(errno));
}
else
{
bv_logd("Init the shared memory[%dKB] OK!", size/1000);
bv_file_log(g_tcp_fp, "Init the shared memory[%dKB] OK!", size/1000);
}
return ;
}The above is copied from others,意思就是说,你先创建了一个KEY对应的文件,比如说是K1,现在程序运行时K1对应的内存SIZE是1000字节,Later you want to expand this memory,Modify the allocated memory directly,最大还是1000字节,只有删掉K1对应的文件,Recreate and allocate larger memory,才能满足.
边栏推荐
- Bika LIMS 开源LIMS集—— SENAITE的使用(分析/测试、方法)
- PyQt5快速开发与实战 7.1 信号与槽介绍
- What is the difference between the legendary server GOM engine and the GEE engine?
- 【JS高级】js之闭包对象_04
- Still developing SMS verification code login?Try it (one-click login with your phone number)
- 推荐几款2022年好用的设备管理系统(软件)
- EA&UML日拱一卒-活动图::Feature和StuctualFeature
- Network connection optimization for instant messaging mobile terminal development
- 为什么字符串使用final关键字
- 企业如何走出固定资产管理的困境?
猜你喜欢
随机推荐
grid的使用
480-82(59、151)
Some thoughts on paying for knowledge
通过二维顺序表实现杨辉三角
少儿编程 电子学会图形化编程等级考试Scratch二级真题解析(选择题)2022年6月
开关电源-半桥LLC控制
基于降噪自编码器与改进卷积神经网络的采煤机健康状态识别
TAP 文章系列-10 | 从应用感知能力谈 TAP 的约定服务
FPGA刷题——跨时钟域传输(FIFO+打拍+握手)
84.(cesium之家)cesium模型在地形上运动
深度解析C语言文件操作以及常见问题
1192. 奖金
rk3399驱动添加电池adc开机检测功能
还在开发短信验证码登录?试试(本机号码一键登录)
中国互联网科技企业群狼围攻,谷歌终于遭受重挫导致利润大跌,它为推动鸿蒙的发展而后悔...
上线前配置
全开放式耳机怎么样?不塞耳朵的蓝牙耳机推荐
C#实现线程管理类
基于变胞机构的移动机器人构型设计研究综述
力扣 206.反转链表--递归解决









