I am trying to avoid race conditions in my code, and I am currently working with a single hyperthreaded CPU, so there are two logical CPUs, each with their own thread. If my understanding of hyperthreading is correct, these threads share the same resources, but their actions are actually time-sliced, not concurrent. Is it still possible for race conditions to emerge between these two hyperthreads?
For example, is there reason for me to change this:
Connection& connection = connections[num_connections];
... do some stuff
++num_connections;
to this:
Connection& connection = connections[num_connections++];
... do some stuff