Thread: Lockless Threaded Queue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> So this is not correct?
    Haven't analyzed it since it was first published, but coming from Herb Sutter it's probably safe to assume that it's correct (at least against the C++0x draft that was available at the time).

    >> or did I misunderstand something?
    C++ volatile isn't even mentioned in that article. atomic<T> from the upcoming C++0x is used to guarantee ordering and memory consistency among threads. Not really related to Posix C.

    More good reading from Herb:
    Dr. Dobb's | Lock-Free Code: A False Sense of Security | September 8, 2008
    Dr. Dobb's | volatile vs. volatile | January 8, 2009

    >> The lock on the front end is really gonna slow me down...
    You don't know this without profiling a working MT-Q, under load.

    Writing correct, wait-free, data structures is extremely difficult in a language like C or C++03 which doesn't define a memory model for the "abstract machine". It would require assembly language and a knowledge of the architecture you're writing for. Even with a well defined memory model, correctness is difficult.

    If on Windows, then assembly language isn't necessarily required, thanks to the Interlocked API's - but correctness is still just as difficult. Which is why there's Interlocked SList as well.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM