summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-02 21:59:54 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-02 21:59:54 +0200
commitf4b232fdc9318a6c8275b35d3201eae5b2e481dd (patch)
tree417b846a269381d0e04c76cb1f68bf1953367922
parentd9d5380bd7b1d6bcc8e8c3fb64da9870008de593 (diff)
kern/spinlock: describe memory order constraints
-rw-r--r--kern/spinlock.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kern/spinlock.c b/kern/spinlock.c
index aa49cffb..68e84215 100644
--- a/kern/spinlock.c
+++ b/kern/spinlock.c
@@ -51,6 +51,16 @@
* and fast paths operations fail. The lock operation must make sure
* that the lock value is restored to SPINLOCK_LOCKED if there is no
* more contention, an operation called downgrading.
+ *
+ * In order to enforce correct visibility of the critical section,
+ * acquire and release atomic operations are used when accessing a
+ * qnode lock. Similarly, acquire and release semantics are also used
+ * when accessing the lock word which stores the first and last QIDs,
+ * so that the memory operations on the qnodes referenced by those QIDs
+ * are correctly enforced. Accessing the next QID in a qnode however
+ * is performed with no memory order constraint, because the qnodes
+ * referenced by those QID are never accessed unless they are the first
+ * or the last, cases which do enforce ordering.
*/
#include <assert.h>