1. ftok()
根据一个路径 返回一个ipc key, 这个路径必须事先存在 否则会返回-1: errno=ENOENT:No such file or directory
2. shmget()
根据ipc key分配一块共享内存, 在linux下, size由系统指定:
/proc/sys/kernel/shmmax
/proc/sys/kernel/shmmin
如果size不在这个范围内, 返回-1 error=EINVAL: A new segment was to be created and size < SHMMIN or size > SHMMAX, or no new segment was to be created, a segment with given key existed,but size is greater than the size of that segment.
并指定权限mode
3. ipcs -m 输出有关共享内存(shared memory)的信息
4. ipcrm -m 删除ipc
ref.
...
阅读(1405) | 评论(0) | 转发(0) |