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

Side by Side Diff: base/threading/platform_thread_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/synchronization/waitable_event_win.cc ('k') | base/threading/platform_thread_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <sched.h> 9 #include <sched.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 #include <sys/resource.h> 12 #include <sys/resource.h>
13 #include <sys/time.h> 13 #include <sys/time.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 16
17 #include <memory> 17 #include <memory>
18 18
19 #include "base/debug/activity_tracker.h"
19 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
20 #include "base/logging.h" 21 #include "base/logging.h"
21 #include "base/threading/platform_thread_internal_posix.h" 22 #include "base/threading/platform_thread_internal_posix.h"
22 #include "base/threading/thread_id_name_manager.h" 23 #include "base/threading/thread_id_name_manager.h"
23 #include "base/threading/thread_restrictions.h" 24 #include "base/threading/thread_restrictions.h"
24 #include "build/build_config.h" 25 #include "build/build_config.h"
25 26
26 #if defined(OS_LINUX) 27 #if defined(OS_LINUX)
27 #include <sys/syscall.h> 28 #include <sys/syscall.h>
28 #endif 29 #endif
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 ThreadPriority priority) { 204 ThreadPriority priority) {
204 PlatformThreadHandle unused; 205 PlatformThreadHandle unused;
205 206
206 bool result = CreateThread(stack_size, false /* non-joinable thread */, 207 bool result = CreateThread(stack_size, false /* non-joinable thread */,
207 delegate, &unused, priority); 208 delegate, &unused, priority);
208 return result; 209 return result;
209 } 210 }
210 211
211 // static 212 // static
212 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 213 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
214 // Record the event that this thread is blocking upon (for hang diagnosis).
215 base::debug::ScopedThreadJoinActivity thread_activity(&thread_handle);
216
213 // Joining another thread may block the current thread for a long time, since 217 // Joining another thread may block the current thread for a long time, since
214 // the thread referred to by |thread_handle| may still be running long-lived / 218 // the thread referred to by |thread_handle| may still be running long-lived /
215 // blocking tasks. 219 // blocking tasks.
216 base::ThreadRestrictions::AssertIOAllowed(); 220 base::ThreadRestrictions::AssertIOAllowed();
217 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL)); 221 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL));
218 } 222 }
219 223
220 // static 224 // static
221 void PlatformThread::Detach(PlatformThreadHandle thread_handle) { 225 void PlatformThread::Detach(PlatformThreadHandle thread_handle) {
222 CHECK_EQ(0, pthread_detach(thread_handle.platform_handle())); 226 CHECK_EQ(0, pthread_detach(thread_handle.platform_handle()));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return ThreadPriority::NORMAL; 286 return ThreadPriority::NORMAL;
283 } 287 }
284 288
285 return internal::NiceValueToThreadPriority(nice_value); 289 return internal::NiceValueToThreadPriority(nice_value);
286 #endif // !defined(OS_NACL) 290 #endif // !defined(OS_NACL)
287 } 291 }
288 292
289 #endif // !defined(OS_MACOSX) 293 #endif // !defined(OS_MACOSX)
290 294
291 } // namespace base 295 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698