Hello, I am working on an assignment that uses multithreading using pthreads in c++. I've created a struct which stores the game data. The fields are:
A void pointer (which I'm using to store a pointer to a multiarray of unsigned chars, created before being passed)
Two integers storing the amount of squares each team possesses
One boolean which stores a true/false value that the supervisor thread will set to make all executing threads exit their loops.
The problem is, I'm getting inaccurate values when attempting to access values from the struct that the pthreads are accessing. I'm using mutexes to lock the threads before accessing the memory at any point, and then unlocking afterwards.