]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: clarify comment for m->locked
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 22 Jul 2013 12:37:31 +0000 (16:37 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 22 Jul 2013 12:37:31 +0000 (16:37 +0400)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11671043

src/pkg/runtime/runtime.h

index 36aff04ad381fc5b53218c21999ca6dc96800b90..f8d45ba819f06864bb458a6a128de5508e897a8e 100644 (file)
@@ -359,9 +359,13 @@ struct P
        byte    pad[64];
 };
 
-// The m->locked word holds a single bit saying whether
-// external calls to LockOSThread are in effect, and then a counter
-// of the internal nesting depth of lockOSThread / unlockOSThread.
+// The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread.
+// The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active.
+// External locks are not recursive; a second lock is silently ignored.
+// The upper bits of m->lockedcount record the nesting depth of calls to lockOSThread
+// (counting up by LockInternal), popped by unlockOSThread (counting down by LockInternal).
+// Internal locks can be recursive. For instance, a lock for cgo can occur while the main
+// goroutine is holding the lock during the initialization phase.
 enum
 {
        LockExternal = 1,