Skip to content
Snippets Groups Projects
Commit fced9ebf authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Fix comments in lfmutex.cc


Trivial fixes to comments in lock-free mutex implementation.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
parent ade5bc3e
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ void mutex::lock() ...@@ -38,7 +38,7 @@ void mutex::lock()
// If we're here the mutex was already locked, but we're implementing // If we're here the mutex was already locked, but we're implementing
// a recursive mutex so it's possible the lock holder is us - in which // a recursive mutex so it's possible the lock holder is us - in which
// case we don't need to increment depth instead of waiting. // case we need to increment depth instead of waiting.
if (owner.load(std::memory_order_relaxed) == current) { if (owner.load(std::memory_order_relaxed) == current) {
count.fetch_add(-1, std::memory_order_relaxed); count.fetch_add(-1, std::memory_order_relaxed);
++depth; ++depth;
...@@ -67,7 +67,7 @@ void mutex::lock() ...@@ -67,7 +67,7 @@ void mutex::lock()
// At this point, waiter.thread() must be != 0, otherwise // At this point, waiter.thread() must be != 0, otherwise
// it means someone has already woken us up, breaking the // it means someone has already woken us up, breaking the
// handoff protocol which decided we should be the ones to // handoff protocol which decided we should be the ones to
// wake somebody up. Note that right after thread->wake() // wake somebody up. Note that right after other->wake()
// below, waiter.thread() may become 0: the thread we woke // below, waiter.thread() may become 0: the thread we woke
// can call unlock() and decide to wake us up. // can call unlock() and decide to wake us up.
assert(waiter.thread()); assert(waiter.thread());
...@@ -83,8 +83,7 @@ void mutex::lock() ...@@ -83,8 +83,7 @@ void mutex::lock()
} }
} }
// Wait until another thread wakes us up. When somebody wakes us, // Wait until another thread pops us from the wait queue and wakes us up.
// they will first zero the value field in our wait record.
trace_mutex_lock_wait(this); trace_mutex_lock_wait(this);
waiter.wait(); waiter.wait();
trace_mutex_lock_wake(this); trace_mutex_lock_wake(this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment