PTHREAD_PROCESS_SHARED permits a mutex/condition to be used by any thread that has access to the memory, even if the mutex/condition is in memory that’s shared by multiple processes. PTHREAD_PROCESS_PRIVATE is the default attribute, which only operates upon threads created within the same process that initialized the mutex/condition. There are two process-shared attribtues in pthread: Pthread mutex and condition also can be used for inter-process synchronization. The source code can be found on my GitHub channel. A read/write lock is also developed to sync the inter-process buffer read/write operations. For the simplicity and efficiency, shared memory is used to store the ring buffer. This post explains how to implment a ring buffer that can be shared between multiple processes.
0 Comments
Leave a Reply. |