c++11 interprocess atomics and mutexes

前端 未结 2 1017
孤独总比滥情好
孤独总比滥情好 2020-12-30 02:13

I have a Linux program which spawns several processes (fork) and communicates through POSIX Shared Memory. I\'d like to have each process allocate an id (0-255). My intentio

2条回答
  •  爱一瞬间的悲伤
    2020-12-30 02:35

    C++11 threading primitives (mutexes, atomics, etc) are threading primitives. They know nothing about processes, and they are not a means of achieving inter-process communication.

    As the C++11 standard makes no mention of processes or inter-process communication, the behavior of such primitives when placed in process-shared memory (a memory-mapped file, some kind of out-of-process globally mapped memory, etc) is undefined.

提交回复
热议问题