libitm: Fix wake-up of readers in futex-based serial lock.
authorTorvald Riegel <triegel@redhat.com>
Tue, 24 Jan 2012 19:17:05 +0000 (19:17 +0000)
committerTorvald Riegel <torvald@gcc.gnu.org>
Tue, 24 Jan 2012 19:17:05 +0000 (19:17 +0000)
libitm/
* config/linux/rwlock.cc (GTM::gtm_rwlock::write_unlock): Fix reader
wake-up.

From-SVN: r183488

libitm/ChangeLog
libitm/config/linux/rwlock.cc

index 4b6d156d750dd0dad5277f2916bbb7154e646dba..9da73d02237428effe4f3f795e52807b48f0046b 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-24  Torvald Riegel  <triegel@redhat.com>
+
+       * config/linux/rwlock.cc (GTM::gtm_rwlock::write_unlock): Fix reader
+       wake-up.
+
 2012-01-24  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/x86/target.h (gtm_jmpbuf) [__x86_64__]: Move rip to the
index 24e7042ff1002574d323d014323073e8c26dfcd6..ad1b042964adefcace1e3ca3f8c941f0a2b73514 100644 (file)
@@ -231,10 +231,13 @@ gtm_rwlock::write_unlock ()
          // last writer (this can happen because write_lock_generic()
          // exchanges 0 or 1 to 2 and thus might go to contended mode even if
          // no other thread holds the write lock currently). Therefore, we
-         // have to wake up readers here as well.
-         futex_wake(&readers, INT_MAX);
+         // have to wake up readers here as well.  Execute a barrier after
+         // the previous relaxed reset of writers (Dekker-style), and fall
+         // through to the normal reader wake-up code.
+         atomic_thread_fence (memory_order_seq_cst);
        }
-      return;
+      else
+       return;
     }
   // No waiting writers, so wake up all waiting readers.
   // Because the fetch_and_sub is a full barrier already, we don't need