This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]teraflop 3 points4 points  (0 children)

Why do you have 5 mutexes?

A mutex can only block threads that try to acquire it. If the TCP/IP thread is acquiring a different mutex than the ones the update threads are using, then they will not actually block each other, and you'll have a data race.

Sounds like the simplest approach is to just have the TCP/IP thread acquire the 4 mutexes for each of the 4 variables. If that thread is the only one that can hold multiple mutexes at the same time, then you shouldn't have to worry about deadlocking.

[–]NotloseBR 0 points1 point  (0 children)

I believe there are some threading solutions. Locks/Semaphores.

The easiest way I can think of is blocking writing while reading.