LINUX 64位下运行32位程序加载和读取大数据段共享内存

LINUX 64位下运行32位程序加载和读取大数据段共享内存

1. 查看当前机器共享内存
1073741824 = 1024 * 1024 * 1024
[root@six shm]# ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status     
0x00000000 0          gdm        600        393216     2          dest        
0x00000000 32769      gdm        600        393216     2          dest        
0x00000000 65538      gdm        600        393216     2          dest        

------ Semaphore Arrays --------
key        semid      owner      perms      nsems    
0x00000000 0          root       600        1        
0x00000000 32769      root       600        1        
0x00000000 65538      apache     600        1        
0x00000000 98307      apache     600        1        
0x00000000 131076     apache     600        1        

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages

共享内存无我们加载的数据,正常。

2 修改需要被加载的文件,指定文件任意位置(1G)修改为随机指定的内容
[root@six shm]# ./modifyfile bigdatafile.dat 1073741824 ABCD1234567890END
read content=ABCD1234567890END,17

3 把大文件bigdatafile.dat(1.11G)加载到共享内存,一个进程一次加载两个,共加载3次
[root@six shm]# ./fileload mykey1 mykey2 bigdatafile.dat
Usage: mykey1 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x64030017
shaddr:0xb0109000,length:1198011173
Usage: mykey2 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x64030018
shaddr:0x68a85000,length:1198011173
[root@six shm]# ./fileload mykey3 mykey4 bigdatafile.dat   
Usage: mykey3 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x6403000d
shaddr:0xb0134000,length:1198011173
Usage: mykey4 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x6403000e
shaddr:0x68ab0000,length:1198011173
[root@six shm]# ./fileload mykey5 mykey6 bigdatafile.dat   
Usage: mykey5 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x6403001b
shaddr:0xb014b000,length:1198011173
Usage: mykey6 KeyFile
 e.g. srcfile:bigdatafile.dat
Key generated by ftok:  0x6403001c
shaddr:0x68ac7000,length:1198011173

4 加载完成,查看有 6.6G的共享内存申请
[root@six shm]# ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status     
0x00000000 0          gdm        600        393216     2          dest        
0x00000000 32769      gdm        600        393216     2          dest        
0x00000000 65538      gdm        600        393216     2          dest        
0x64030017 589827     root       0          1198011173 0                      
0x64030018 622596     root       0          1198011173 0                      
0x6403000d 655365     root       0          1198011173 0                      
0x6403000e 688134     root       0          1198011173 0                      
0x6403001b 720903     root       0          1198011173 0                      
0x6403001c 753672     root       0          1198011173 0                      

------ Semaphore Arrays --------
key        semid      owner      perms      nsems    
0x00000000 0          root       600        1        
0x00000000 32769      root       600        1        
0x00000000 65538      apache     600        1        
0x00000000 98307      apache     600        1        
0x00

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值