Thread: Trying to understand hazard pointer implementation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    https://gcc.gnu.org/onlinedocs/gcc/_...-Builtins.html
    >> __ATOMIC_ACQUIRE - Creates an inter-thread happens-before constraint from the release (or stronger) semantic store to this acquire load. Can prevent hoisting of code to before the operation.
    In other words, it prevents loads/stores from moving before the Acquire.

    Acquire and Release Semantics

    gg

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    83
    Quote Originally Posted by Codeplug View Post
    https://gcc.gnu.org/onlinedocs/gcc/_...-Builtins.html
    __ATOMIC_ACQUIRE - Creates an inter-thread happens-before constraint from the release (or stronger) semantic store to this acquire load. Can prevent hoisting of code to before the operation.
    In other words, it prevents loads/stores from moving before the Acquire.
    I may be completely missing something here - I hope not :-) but that does not, according to my mental picture of what's going on with all this stuff, address the problem in any way.

    The loads which occur in the reader thread are c0 and c1. They indeed will not be moved above the load barrier - but the problem is not that they are moved; the problem is that the read thread pauses after the load barrier, while the write thread continues.

    One minor point - being an acquire fence, it will only prevent *loads* from moving up above the fence, not stores as well.

    Would you describe how you see the code in the two threads working (your version of the code, with the acquire right after the label), with regard to loads, stores, barriers, etc?
    Last edited by Toby Douglass; 01-20-2017 at 09:05 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestion Smart Pointer Class Implementation
    By Bargi in forum C++ Programming
    Replies: 4
    Last Post: 02-09-2015, 06:57 AM
  2. This Program may help you to understand pointer
    By papagym177 in forum C++ Programming
    Replies: 1
    Last Post: 07-29-2014, 05:21 AM
  3. Replies: 2
    Last Post: 03-17-2014, 01:48 PM
  4. Help for understand pointer
    By redred in forum C Programming
    Replies: 8
    Last Post: 01-19-2013, 01:41 PM
  5. Don't understand backtrace on invalid pointer
    By SterlingM in forum C++ Programming
    Replies: 5
    Last Post: 09-21-2011, 02:00 PM

Tags for this Thread