今天在hcorr上完成了share memory的测试。
通过PCI驱动存取LTA数据并通过PGPLOT实时刷新显示。
工作流程:
include
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/shm.h>
create share memory
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
shm_id = shmget(shm_key_id, SHM_BUF_SIZE, 0666);
while (shm_id < 0) {
printf("waiting the share memory content ...%d\r", j++);
sleep(1);
}
shm_data_buf = shmat(shm_id, 0, 1);