 <p>Clearly this operation is not thread-safe since, as you mentioned yourself, it involves several assembler instructions. In fact, openMP even has a special directive for this kind of operations.</p> <p>You will need the <code>atomic</code> pragma to make it, well, "atomic":</p> <pre><code>#pragma omp atomic totalTime += elapsedTime; </code></pre> <p>Note that <code>atomic</code> only works when you have a single update to a memory location, like an addition, increment, etc.</p> <p>If you have a series of instructions that need to atomic together you must use the <code>critical</code> directive:</p> <pre><code>#pragma omp critical { // atomic sequence of instructions } </code></pre> <p><strong>Edit</strong>: Here's a good suggestion from "snemarch": If you are repeatedly updating the global variable <code>totalTime</code> in a parallel loop you can consider using the <code>reduction</code> clause to automatize the process and also make it much more efficient:</p> <pre><code>double totalTime = 0; #pragma omp parallel for reduction(+:totalTime) for(...) { ... totalTime += elapsedTime; } </code></pre> <p>At the end <code>totalTime</code> will correctly contain the sum of the local <code>elapsedTime</code> values without need for explicit synchronization.</p>