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

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: more clean-up and addressed review comments Created 4 years, 6 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
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 14
15 #include <memory> 15 #include <memory>
16 16
17 #include "base/debug/activity_tracker.h"
17 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/threading/platform_thread_internal_posix.h" 20 #include "base/threading/platform_thread_internal_posix.h"
20 #include "base/threading/thread_id_name_manager.h" 21 #include "base/threading/thread_id_name_manager.h"
21 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 24
24 #if defined(OS_LINUX) 25 #if defined(OS_LINUX)
25 #include <sys/syscall.h> 26 #include <sys/syscall.h>
26 #elif defined(OS_ANDROID) 27 #elif defined(OS_ANDROID)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { 196 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) {
196 PlatformThreadHandle unused; 197 PlatformThreadHandle unused;
197 198
198 bool result = CreateThread(stack_size, false /* non-joinable thread */, 199 bool result = CreateThread(stack_size, false /* non-joinable thread */,
199 delegate, &unused, ThreadPriority::NORMAL); 200 delegate, &unused, ThreadPriority::NORMAL);
200 return result; 201 return result;
201 } 202 }
202 203
203 // static 204 // static
204 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 205 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
206 // Record the event that this thread is blocking upon (for hang diagonsis).
manzagop (departed) 2016/06/16 15:19:41 typo: diagonsis
207 base::debug::ScopedThreadJoinActivity thread_activity(&thread_handle);
208
205 // Joining another thread may block the current thread for a long time, since 209 // Joining another thread may block the current thread for a long time, since
206 // the thread referred to by |thread_handle| may still be running long-lived / 210 // the thread referred to by |thread_handle| may still be running long-lived /
207 // blocking tasks. 211 // blocking tasks.
208 base::ThreadRestrictions::AssertIOAllowed(); 212 base::ThreadRestrictions::AssertIOAllowed();
209 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL)); 213 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL));
210 } 214 }
211 215
212 // Mac has its own Set/GetCurrentThreadPriority() implementations. 216 // Mac has its own Set/GetCurrentThreadPriority() implementations.
213 #if !defined(OS_MACOSX) 217 #if !defined(OS_MACOSX)
214 218
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return ThreadPriority::NORMAL; 261 return ThreadPriority::NORMAL;
258 } 262 }
259 263
260 return internal::NiceValueToThreadPriority(nice_value); 264 return internal::NiceValueToThreadPriority(nice_value);
261 #endif // !defined(OS_NACL) 265 #endif // !defined(OS_NACL)
262 } 266 }
263 267
264 #endif // !defined(OS_MACOSX) 268 #endif // !defined(OS_MACOSX)
265 269
266 } // namespace base 270 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698