免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2324 | 回复: 2

mmap的疑问? [复制链接]

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
发表于 2011-11-06 22:23 |显示全部楼层
通常mmap用来实现不同进程之间共享内存,即把某个文件映射到不同的进程中,mmap的参数fd等于文件的描述符,今天在看代码的时候,发现mmap的fd参数等于-1,这种用法通常的目的是啥?
        
code_gen_buffer = mmap(start, size,PROT_WRITE | PROT_READ | PROT_EXEC,flags, -1, 0);

论坛徽章:
0
发表于 2011-11-07 10:33 |显示全部楼层
mmap(2):

MAP_ANONYMOUS
              The mapping is not backed by any file; its contents are initialized to zero.  The fd and  offset  arguments
              are ignored; however, some implementations require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified,
              and portable applications should ensure this.  The use of MAP_ANONYMOUS in conjunction with  MAP_SHARED  is
              only supported on Linux since kernel 2.4.

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
发表于 2011-11-07 11:31 |显示全部楼层
回复 1# liujunwei1234
man一下吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP