I am running a multi-threaded socket program with valgrind. The client will send a request to the server via TCP, and then busy waiting at the logical level. A boolean value will be set when the callback function that serves the response from the server is called. After receiving the response (and the boolean flag is set), the server will again send the request and do it again in a loop.
I understand that unchecked access to shared variables (logical) can cause problems with threads, but I tried to use pthread mutexes, and the program slows down by about 20% (speed is important here). I am sure that writing to a shared boolean is fine, as it can be done in a single loop.
The program works fine outside of valgrind, but often stops when it starts with valgrind. I left the program to run overnight. It usually takes only a few seconds to complete, so I don’t think this is the case when you do not wait long enough for the program to end. Thread management is done using the open source framework (quick fix), so I don't think this is a problem with thread creation / management.
Does anyone know of any problems with valgrind around multi-threaded programs / busy waiting / socket communication cycles (or a combination thereof)?
source
share