Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2005-04-08 11:17:11

Alexander Terekhov wrote:
> That (preliminary) notice doesn't really say what's the problem
> with respect to "dangling" reservation. (Context switch of course
> must clear reservation; everybody and his dog knows that.)

Just to clarify. Think of simple unconditional increments on UP
(count is zero initially).

   Thread A: <load-reserved>
             <add 1>

   [preemptive context switch]

   Thread B: <load-reserved>
             <add 1>
             <store-conditional> // count = 1
             [another increment, count = 2]
             [begin yet another increment]

   [preemptive context switch]

   Thread A: <store-conditional> // count = 1

And you've just lost one billion dollars.

In any preemptive OS context switch must always clear reservation
to ensure that you never get into this sort of trouble.


Boost list run by bdawes at, gregod at, cpdaniel at, john at