use share memory

I need tranfer information between two processes,process A receices some data from several nodes by TCP socket(the internal time is 10ms),process B is in charge of managing the data and send it to another computer,now I use share memory to achive it,but I find it very difficult to let process B to know whether all the data is arrived,I have to use usleep()
to delay some time and then check it,btw,Do I need use semphore to visit share memory if I only read it?Could you give me some advice?

usleep is bad.

You can use semaphores to lock the process B until there is something valid in sharemem, but thats only going to work if process B has nothing else do to ( like handling timer or incomming messages). You could use pulses or messages for notification.

Or turn process A into a thread that runs into process B ( that’s what I would do ).

Or let process B handle the TCP connections and the transmission.