| OLD | NEW |
| 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 <sched.h> | 8 #include <sched.h> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/safe_strerror_posix.h" | 13 #include "base/safe_strerror_posix.h" |
| 14 #include "base/threading/thread_id_name_manager.h" | 14 #include "base/threading/thread_id_name_manager.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
| 17 | 17 |
| 18 #if !defined(OS_NACL) | 18 #if !defined(OS_NACL) |
| 19 #include <sys/prctl.h> | 19 #include <sys/prctl.h> |
| 20 #include <sys/resource.h> | 20 #include <sys/resource.h> |
| 21 #include <sys/syscall.h> | 21 #include <sys/syscall.h> |
| 22 #include <sys/time.h> | 22 #include <sys/time.h> |
| 23 #include <unistd.h> | 23 #include <unistd.h> |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 #if !defined(OS_NACL) |
| 30 int ThreadNiceValue(ThreadPriority priority) { | 31 int ThreadNiceValue(ThreadPriority priority) { |
| 31 switch (priority) { | 32 switch (priority) { |
| 32 case kThreadPriority_RealtimeAudio: | 33 case kThreadPriority_RealtimeAudio: |
| 33 return -10; | 34 return -10; |
| 34 case kThreadPriority_Background: | 35 case kThreadPriority_Background: |
| 35 return 10; | 36 return 10; |
| 36 case kThreadPriority_Normal: | 37 case kThreadPriority_Normal: |
| 37 return 0; | 38 return 0; |
| 38 case kThreadPriority_Display: | 39 case kThreadPriority_Display: |
| 39 return -6; | 40 return -6; |
| 40 default: | 41 default: |
| 41 NOTREACHED() << "Unknown priority."; | 42 NOTREACHED() << "Unknown priority."; |
| 42 return 0; | 43 return 0; |
| 43 } | 44 } |
| 44 } | 45 } |
| 46 #endif // !defined(OS_NACL) |
| 45 | 47 |
| 46 } // namespace | 48 } // namespace |
| 47 | 49 |
| 48 // static | 50 // static |
| 49 void PlatformThread::SetName(const char* name) { | 51 void PlatformThread::SetName(const char* name) { |
| 50 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); | 52 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); |
| 51 tracked_objects::ThreadData::InitializeThreadContext(name); | 53 tracked_objects::ThreadData::InitializeThreadContext(name); |
| 52 | 54 |
| 53 #if !defined(OS_NACL) | 55 #if !defined(OS_NACL) |
| 54 // On linux we can get the thread names to show up in the debugger by setting | 56 // On linux we can get the thread names to show up in the debugger by setting |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 #if !defined(THREAD_SANITIZER) | 112 #if !defined(THREAD_SANITIZER) |
| 111 return 0; | 113 return 0; |
| 112 #else | 114 #else |
| 113 // ThreadSanitizer bloats the stack heavily. Evidence has been that the | 115 // ThreadSanitizer bloats the stack heavily. Evidence has been that the |
| 114 // default stack size isn't enough for some browser tests. | 116 // default stack size isn't enough for some browser tests. |
| 115 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). | 117 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). |
| 116 #endif | 118 #endif |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace base | 121 } // namespace base |
| OLD | NEW |