Skip to content
Advertisement

sharing read-write lock between interprocess

I have two processes rwlock1(parent) and rwlock2(child) . i want to use read-writer lock between processes , i need to transfer pthread_rwlock_t mem_lock to child process, i have a simple code , how can i trasfer the handle . i dont want to use a mutex.

rwlock1(parent)’s code

JavaScript

Advertisement

Answer

I haven’t tried, but it looks like this can be done if you put the lock in shared memory (e.g. set up by mmap or shmget) and use pthread_rwlockattr_setpshared to set the lock as process-shared.

See also 2.9.9 Synchronization Object Copies and Alternative Mappings in IEEE Std 1003.1-2017.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement