class LockDependencySet
Defined at line 24 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
A lock-free, wait-free hash set that tracks the set of lock classes that have
been acquired prior the lock class that owns the set. Each lock class
maintains its own dependency set.
Implementation note: This hash set makes use of relaxed atomic operations.
This approach is appropriate because the only variables communicated between
threads are the values of the atomic variables themselves, other loads and
stores are not published. Additionally, sequential consistency within a
thread is ensured due to control dependencies only on the atomic variables.
Public Methods
void LockDependencySet ()
Defined at line 26 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
void LockDependencySet (const LockDependencySet & )
Defined at line 27 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
void operator= (const LockDependencySet & )
Defined at line 28 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
void LockDependencySet (LockDependencySet && )
Defined at line 29 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
void operator= (LockDependencySet && )
Defined at line 30 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
bool HasLockClass (LockClassId id)
Checks the dependency hash set for the given lock class. This method may
safely race with AddLockClass(), converging on the correct answer by the
next check.
Defined at line 35 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
LockResult AddLockClass (LockClassId id)
Adds the given lock class id to the dependency set if not already present.
Updates the set using the following lock free approach:
1. The dependency set is fixed size and all entries start out empty.
2. New entries are added using open addressing with linear probing.
3. An entry may only change from empty to holding a lock class id.
4. To add an entry the set is probed linearly until either:
a) The id to add appears in the set already.
b) The first empty entry is found.
c) The entire set has been probed; return max dependencies error.
5. Attempt to compare-exchange the empty entry with the lock class id:
a) If the update succeeds return success.
b) If the update does not succeed but the winning value is the same
lock class id return with success.
c) If the update does not succeed and the winning value is a different
lock class id proceed to the next entry and continue the probe from
step #4.
Defined at line 63 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
Iterator begin ()
Iterator accessors.
Defined at line 113 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
Iterator end ()
Defined at line 120 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h
void clear ()
Clears the dependency set. This method is not used by the main algorithm
but may be useful for unit tests and benchmarking. Until lock sequence
memoization is implemented it is generally safe to call this method at
any time, resulting in dependency set being rebuilt at runtime. Once
lock sequence memoization is implemented it is necessary to clear the
memoization table whenever any dependency set is cleared so that the
dependency set can be rebuilt; failure to do so could result in missing
new lock violations.
Defined at line 130 of file ../../zircon/system/ulib/lockdep/include/lockdep/lock_dependency_set.h