Lines Matching refs:lock

27  * LockGuard is a mechanism to help detect lock inversions inside the system
28 * server. It works by requiring each lock acquisition site to follow this
32 * synchronized (LockGuard.guard(lock)) {
44 * {@code ActivityManager} lock while holding the {@code PackageManager} lock,
54 * <li>A guarded synchronized block takes 460ns per lock checked when enabled.
67 * should never be acquired while holding a lock of a lower index.
82 /** Friendly label to describe this lock */
85 /** Child locks that can be acquired while this lock is already held */
89 private static LockInfo findOrCreateLockInfo(Object lock) {
90 LockInfo info = sKnown.get(lock);
93 info.label = "0x" + Integer.toHexString(System.identityHashCode(lock)) + " ["
95 sKnown.put(lock, info);
103 * @param lock The lock the calling thread is attempting to acquire.
105 public static Object guard(Object lock) {
106 // If we already hold this lock, ignore
107 if (lock == null || Thread.holdsLock(lock)) return lock;
111 final LockInfo info = findOrCreateLockInfo(lock);
119 + lockToString(lock), new Throwable());
125 // If no trouble found above, record this lock as being a valid
129 if (test == null || test == lock) continue;
132 sKnown.valueAt(i).children.add(lock);
137 return lock;
142 * is about to acquire the given lock.
146 final Object lock = sKnownFixed[i];
147 if (lock != null && Thread.holdsLock(lock)) {
156 * Report the given lock with a well-known label.
158 public static Object installLock(Object lock, String label) {
159 final LockInfo info = findOrCreateLockInfo(lock);
161 return lock;
165 * Report the given lock with a well-known index.
167 public static Object installLock(Object lock, int index) {
168 sKnownFixed[index] = lock;
169 return lock;
173 final Object lock = new Object();
174 installLock(lock, index);
175 return lock;
178 private static String lockToString(Object lock) {
179 final LockInfo info = sKnown.get(lock);
183 return "0x" + Integer.toHexString(System.identityHashCode(lock));
202 final Object lock = sKnown.keyAt(i);
204 pw.println("Lock " + lockToString(lock) + ":");