Race conditions are one of the ugliest type of bug
to detect and fix, mainly because they are not reproducible
. Even if all process
es involved are started in the same order and with the same time difference, they will most likely arrive at the critical section differently than before, due to interrupt
So if the race condition only manifests with a timing scenario that occurs with a very low probability, it becomes very hard to observe when you are actually looking for it. If you absolutely have to find it because the results are catastrophic and must not occur even infrequently, you're pretty screwed.
The way to deal with race conditions is to not let them come into being in the first place, by paying the utmost attention to correctly dealing with shared resources in the design stage, not in the debugging stage.