c内存共享
来源:互联网 发布:模块数据出现异常400 编辑:程序博客网 时间:2024/06/05 00:27
c内存共享
int segment_id = shmget (shm_key, getpagesize (),IPC_CREAT | S_IRUSR | S_IWUSER); shared_memory = (char*) shmat (segment_id, 0, 0); shmctl (segment_id, IPC_STAT, &shmbuffer); int main(){ int shm_id; int *share; int num; srand(time(NULL)); shm_id = shmget (1234, getpagesize(), IPC_CREAT); if(shm_id == -1){ perror("shmget()"); } share = (int *)shmat(shm_id, 0, 0); while(1){ num = random() % 1000; *share = num; printf("write a random number %d\n", num); sleep(1); } return 0; }int main(){ int shm_id; int *share; shm_id = shmget (1234, getpagesize(), IPC_CREAT); if(shm_id == -1){ perror("shmget()"); } share = (int *)shmat(shm_id, 0, 0); while(1){ sleep(1); printf("%d\n", *share); } return 0; }
阅读全文
1 0
- C语言 共享内存
- C linux 共享内存
- c内存共享
- linux-c: ipc_共享内存
- linux C共享内存函数
- linux C共享内存1
- linux c 共享内存编程
- 5. linux C -- 共享内存
- 【C语言】【unix c】共享内存
- Linux C 消息队列和共享内存
- linux c 共享内存编程学习记录
- linux下C的共享内存编程
- C语言共享内存-基本操作
- Android 匿名共享内存C接口分析
- win平台C语言共享内存通信
- Linux C——共享内存
- Android 匿名共享内存C接口分析
- Java与VC/C/C++共享内存
- 【怎样写代码】工厂三兄弟之抽象工厂模式(三):产品等级结构与产品族
- 1.html基础知识
- spark学习笔记之一:RDD的五大特性
- Redis-Migrate-Tool 使用详解2
- Linux yum详解
- c内存共享
- 数组【从入门到精通】
- 尚硅谷-Maven学习笔记
- hearbeat of RAC
- 计算两个整型数组元素之和
- 向下拖拽展示更多之自定义 RecyclerView
- LeetCode-7.Reverse Integer
- 2017 多校2 c题(水题 贪心)
- 设置tablayout下划线的宽度