how to use shared memory to communicate between two processes

前端 未结 3 728
面向向阳花
面向向阳花 2020-12-14 04:14

I am trying to communicate between two processes. I am trying to save data(like name, phone number, address) to shared memory in one process and trying to print that data th

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 04:20

    You should be reserving enough shared memory to exchange the data. Processes aren't supposed to access each others memory, even if using shared pointers. Keep in mind only the raw data you write during runtime is shared, there's no type checking or any other metadata passed. You can use a common structure, if your data allows it using fixed-size arrays, to access the data more easily. Otherwise, you'll have to manually marshal the data between the processes.

提交回复
热议问题