- 0
- 0
- 约9.99千字
- 约 10页
- 2026-01-24 发布于北京
- 举报
用共享内存传递数据
2SystemV共享内存API
共享内存数据结构及基本API
_
structshmidds{
__
structipcpermshmperm;/*所有者和权限*/
_
_shmsegsz;/*段大小(字节)*/
sizet
_
_shmatime;/*最后附加时间*/
timet
_
_shmdtime;/*最后分离时间*/
timet
_
_shmctime;/*最后更改时间*/
timet
__
pidtshmcpid;/*创建者的PID*/
_
shmlpid;/*最后一次shmat(2)/shmdt(2)的PID*/
_
pidt
__
shmatttshmnattch;/*当前连接数*/
...
};
共享内存函数
#includesys/ipc.h
#includesys/shm.h
__
intshmget(keytkey,sizetsize,intshmflg);
void*shmat(intshmid,constvoid*shmaddr,intshmflg);
intshmdt(constvoid*shmaddr);
_
intshmctl(intshmid,intcmd,structshmidds*buf);
用共享内存传递数据
2SystemV共享内存API
共享内存数据结构及基本API
structshmid_ds{
structipc_permshm_perm;/*Ownershipandpermissions*/
size_tshm_segsz;/*Sizeofsegment(bytes)*/
time_tshm_atime;/*Lastattachtime*/
time_tshm_dtime;/*Lastdetachtime*/
time_tshm_ctime;/*Lastchangetime*/
pid_tshm_cpid;/*PIDofcreato
原创力文档

文档评论(0)