今天完成了share memory的测试
今天在hcorr上完成了share memory的测试。
通过PCI驱动存取LTA数据并通过PGPLOT实时刷新显示。
工作流程:
1 2 3
| #include<sys/types.h> #include<sys/ipc.h> #include<sys/shm.h>
|
create share memory
1 2 3 4 5 6 7 8 9 10 11
| shm_id = shmget(shm_key_id, SHM_BUF_SIZE, 0666|IPC_CREAT);
if (shm_id < 0) {
perror(“share memory error.”);
exit(1);
}
shm_data_buf= shmat(shm_id,0,1);
|
using share memory
1 2 3 4 5 6 7 8 9 10 11
| shm_id = shmget(shm_key_id, SHM_BUF_SIZE, 0666);
while (shm_id < 0) {
printf(“waiting the share memory content …%dr”, j++);
sleep(1);
}
shm_data_buf = shmat(shm_id, 0, 1);
|