]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix comment
authorDmitry Vyukov <dvyukov@google.com>
Fri, 13 Mar 2015 13:02:47 +0000 (16:02 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 17 Mar 2015 15:23:20 +0000 (15:23 +0000)
IRIW requires 4 threads: first writes x, second writes y,
third reads x and y, fourth reads y and x.
This is Peterson/Dekker mutual exclusion algorithm based on
critical store-load sequences:
http://en.wikipedia.org/wiki/Dekker's_algorithm
http://en.wikipedia.org/wiki/Peterson%27s_algorithm

Change-Id: I30a00865afbe895f7617feed4559018f81ff4528
Reviewed-on: https://go-review.googlesource.com/7561
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbarrier.go

index f6e92698580ed5e8aa03b1afdef252c4857f2afd..1f9bd95cae7678849a5b850b2a7fc7616653fc3f 100644 (file)
@@ -53,11 +53,13 @@ import "unsafe"
 //
 // ld r1, [slotmark]       ld r2, [slot]
 //
-// This is a classic example of independent reads of independent writes,
-// aka IRIW. The question is if r1==r2==0 is allowed and for most HW the
-// answer is yes without inserting a memory barriers between the st and the ld.
-// These barriers are expensive so we have decided that we will
-// always grey the ptr object regardless of the slot's color.
+// Without an expensive memory barrier between the st and the ld, the final
+// result on most HW (including 386/amd64) can be r1==r2==0. This is a classic
+// example of what can happen when loads are allowed to be reordered with older
+// stores (avoiding such reorderings lies at the heart of the classic
+// Peterson/Dekker algorithms for mutual exclusion). Rather than require memory
+// barriers, which will slow down both the mutator and the GC, we always grey
+// the ptr object regardless of the slot's color.
 //go:nowritebarrier
 func gcmarkwb_m(slot *uintptr, ptr uintptr) {
        switch gcphase {