共享内存创建失败(已经存在)时如何获得已创建的共享内存?
(2012-04-11 01:25:29)
标签:
内存
如何
杂谈
共享内存创建失败(已经存在)时如何获得已创建的共享内存?如果共享内存创建失败,shmget返回-1,errno为EEXIST表示共享内存已经被创建,那么如何获得这个已经创建的共享内存进行使用呢?shm与一个key关联的吧,用shm不多,我一直用mmap.原帖由
converse 于 2008-11-11 15:08 发表
http://bbs.chinaunix.net/images/common/back.gif
shm与一个key关联的吧,用shm不多,我一直用mmap.
知道了http://www.hengxingzulin.com,shmget函数还可以直接使用已经创建的共享内存,如果参数shmflag不为IPC_EXCL,当发现已经创建的好的,调用不会失败!原帖由
converse 于 2008-11-11 15:08 发表
http://bbs.chinaunix.net/images/common/back.gif
shm与一个key关联的吧,用shm不多,我一直用mmap.
mmap有什么优势?跟shm有什么区别?
flags
Specifies the creation options. Possible values are:
IPC_CREAT
If the specified key does not exist, the shmget() function
creates a shared memory identifier for the specified key.
If the specified key does exist, and IPC_EXCL is not set, the
shared memory identifier for the specified key is returned.
If the specified key does exist and IPC_EXCL is set, the
shmget() function fails and returns an error.
分享:
喜欢
0
赠金笔
加载中,请稍候......
评论加载中,请稍候...
发评论
登录名: 密码: 找回密码 注册记住登录状态
昵 称:
评论并转载此博文
发评论
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。