Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: base/synchronization/lock_impl_posix.cc

Issue 1980743002: Track thread activities in order to diagnose hangs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@readwrite-mmf
Patch Set: rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/process_win.cc ('k') | base/synchronization/lock_impl_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/synchronization/lock_impl.h" 5 #include "base/synchronization/lock_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/debug/activity_tracker.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 13
13 namespace base { 14 namespace base {
14 namespace internal { 15 namespace internal {
15 16
16 // Determines which platforms can consider using priority inheritance locks. Use 17 // Determines which platforms can consider using priority inheritance locks. Use
17 // this define for platform code that may not compile if priority inheritance 18 // this define for platform code that may not compile if priority inheritance
18 // locks aren't available. For this platform code, 19 // locks aren't available. For this platform code,
19 // PRIORITY_INHERITANCE_LOCKS_POSSIBLE() is a necessary but insufficient check. 20 // PRIORITY_INHERITANCE_LOCKS_POSSIBLE() is a necessary but insufficient check.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DCHECK_EQ(rv, 0) << ". " << strerror(rv); 53 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
53 } 54 }
54 55
55 bool LockImpl::Try() { 56 bool LockImpl::Try() {
56 int rv = pthread_mutex_trylock(&native_handle_); 57 int rv = pthread_mutex_trylock(&native_handle_);
57 DCHECK(rv == 0 || rv == EBUSY) << ". " << strerror(rv); 58 DCHECK(rv == 0 || rv == EBUSY) << ". " << strerror(rv);
58 return rv == 0; 59 return rv == 0;
59 } 60 }
60 61
61 void LockImpl::Lock() { 62 void LockImpl::Lock() {
63 base::debug::ScopedLockAcquireActivity lock_activity(this);
62 int rv = pthread_mutex_lock(&native_handle_); 64 int rv = pthread_mutex_lock(&native_handle_);
63 DCHECK_EQ(rv, 0) << ". " << strerror(rv); 65 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
64 } 66 }
65 67
66 void LockImpl::Unlock() { 68 void LockImpl::Unlock() {
67 int rv = pthread_mutex_unlock(&native_handle_); 69 int rv = pthread_mutex_unlock(&native_handle_);
68 DCHECK_EQ(rv, 0) << ". " << strerror(rv); 70 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
69 } 71 }
70 72
71 // static 73 // static
(...skipping 15 matching lines...) Expand all
87 // Fixed in glibc 2.17. 89 // Fixed in glibc 2.17.
88 // Priority inheritance mutexes may deadlock with condition variables 90 // Priority inheritance mutexes may deadlock with condition variables
89 // during recacquisition of the mutex after the condition variable is 91 // during recacquisition of the mutex after the condition variable is
90 // signalled. 92 // signalled.
91 return false; 93 return false;
92 #endif 94 #endif
93 } 95 }
94 96
95 } // namespace internal 97 } // namespace internal
96 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_win.cc ('k') | base/synchronization/lock_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698