
[quick post, have some more in my outbox, but i'm at a conference this week, where they cut imap/smtp ports]
Anyway, what's the "wrong order?" If one thread is depending on the order of things that happen in another thread without both threads using the synchronization necessary to ensure that order, it's a race condition (a.k.a. a bug), right?
All of the classic lock-free algorithms, including those that are the basis for the synchronization primitives we should usually use, have data races. At a low level it is sometimes necessary to use a variable for synchronization.
the fifo code for example contains code like: atomic<> head_, tail_; head = head_.load(); tail = tail_.load(); head2 = head_.load(); if (head == head2) do something the correctness of this algorithm depends on the order of the loads: load head before tail and load tail before head2. without a memory model, both the compiler and the CPU are allowed to reorder loads (or head2 could simply use the value of head without actually reloading it) cheers, tim --------------------------------------------------------------- diese nachricht wurde ueber klingt.org gesendet this message was sent through klingt.org's webmail.