Linux Shared Memory Synchronization

后端 未结 4 556
天命终不由人
天命终不由人 2021-02-06 03:24

I have implemented two applications that share data using the POSIX shared memory API (i.e. shm_open). One process updates data stored in the shared memory segment

4条回答
  •  被撕碎了的回忆
    2021-02-06 04:00

    If efficiency is important, I would go with process-shared mutexes and condition variables.

    AFAIR, each operation with a semaphore requires a syscall, so uncontended mutex should be faster than the semaphore [ab]used in mutex-like manner.

提交回复
热议问题