about summary refs log tree commit diff
path: root/nptl/lowlevelrobustlock.c
diff options
context:
space:
mode:
authorTorvald Riegel <triegel@redhat.com>2014-12-15 22:49:29 +0100
committerTorvald Riegel <triegel@redhat.com>2014-12-15 22:49:29 +0100
commitd52c62df3d7574906dde1dea23f8a71e85073b06 (patch)
treeb2c4adc4eca4da3caead86e0420b03365897ed1a /nptl/lowlevelrobustlock.c
parent045a6bcdd2d9c5c83f01171775998ef3104eb10f (diff)
downloadglibc-d52c62df3d7574906dde1dea23f8a71e85073b06.tar.gz
glibc-d52c62df3d7574906dde1dea23f8a71e85073b06.tar.xz
glibc-d52c62df3d7574906dde1dea23f8a71e85073b06.zip
Add comments for the generic lowlevellock implementation.
Patch by Bernard Ogden <bernie.ogden@linaro.org>.
Diffstat (limited to 'nptl/lowlevelrobustlock.c')
-rw-r--r--nptl/lowlevelrobustlock.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/nptl/lowlevelrobustlock.c b/nptl/lowlevelrobustlock.c
index 35258071cf..291d32a5ce 100644
--- a/nptl/lowlevelrobustlock.c
+++ b/nptl/lowlevelrobustlock.c
@@ -36,14 +36,17 @@ __lll_robust_lock_wait (int *futex, int private)
 
   do
     {
+      /* If the owner died, return the present value of the futex.  */
       if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED))
 	return oldval;
 
+      /* Try to put the lock into state 'acquired, possibly with waiters'.  */
       int newval = oldval | FUTEX_WAITERS;
       if (oldval != newval
 	  && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
 	continue;
 
+      /* If *futex == 2, wait until woken.  */
       lll_futex_wait (futex, newval, private);
 
     try:
@@ -67,7 +70,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime,
   int tid = THREAD_GETMEM (THREAD_SELF, tid);
   int oldval = *futex;
 
-  /* If the futex changed meanwhile try locking again.  */
+  /* If the futex changed meanwhile, try locking again.  */
   if (oldval == 0)
     goto try;
 
@@ -100,15 +103,17 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime,
 	return ETIMEDOUT;
 #endif
 
-      /* Wait.  */
+      /* If the owner died, return the present value of the futex.  */
       if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED))
 	return oldval;
 
+      /* Try to put the lock into state 'acquired, possibly with waiters'.  */
       int newval = oldval | FUTEX_WAITERS;
       if (oldval != newval
 	  && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
 	continue;
 
+      /* If *futex == 2, wait until woken or timeout.  */
 #if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \
      || !defined lll_futex_timed_wait_bitset)
       lll_futex_timed_wait (futex, newval, &rt, private);