I have a producer process that will update a shared variable and updated value of shared variable will be read by many consumer processes.
Producer can only update shared variable if all the consumers have read it. To implement this, I need to know number of consumer processes, which can change dynamically. What is the best way to achieve this?
I can try maintaining count of consumer processes by incrementing a shared variable when consumer process is initialized and decrement when consumer process is closed.
However how to take care of scenario, if consumer process is killed or crashes. Is there a way to find number of processes subscribed to a shared memory?