Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/threading/thread_id_name_manager.h" | 13 #include "base/threading/thread_id_name_manager.h" |
| 14 #include "base/tracked_objects.h" | 14 #include "base/tracked_objects.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 | 16 |
| 17 #if !defined(OS_NACL) | 17 #if !defined(OS_NACL) |
| 18 #include <pthread.h> | 18 #include <pthread.h> |
| 19 #include <sys/prctl.h> | |
|
l2dy
2015/12/28 11:05:45
404 in FreeBSD
| |
| 20 #include <sys/types.h> | 19 #include <sys/types.h> |
| 21 #include <unistd.h> | 20 #include <unistd.h> |
| 22 #endif | 21 #endif |
| 23 | 22 |
| 24 namespace base { | 23 namespace base { |
| 25 | 24 |
| 26 namespace internal { | 25 namespace internal { |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 #if !defined(OS_NACL) | 28 #if !defined(OS_NACL) |
| 30 const struct sched_param kRealTimePrio = {8}; | 29 const struct sched_param kRealTimePrio = {8}; |
| 31 #endif | 30 #endif |
| 32 } // namespace | 31 } // namespace |
| 33 | 32 |
| 34 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { | 33 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { |
| 35 {ThreadPriority::BACKGROUND, 10}, | 34 {ThreadPriority::BACKGROUND, 10}, |
| 36 {ThreadPriority::NORMAL, 0}, | 35 {ThreadPriority::NORMAL, 0}, |
| 37 {ThreadPriority::DISPLAY, -6}, | 36 {ThreadPriority::DISPLAY, -6}, |
| 38 {ThreadPriority::REALTIME_AUDIO, -10}, | 37 {ThreadPriority::REALTIME_AUDIO, -10}, |
| 39 } | 38 }; |
|
l2dy
2015/12/28 11:05:45
the missing semicolon
| |
| 40 | 39 |
| 41 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) { | 40 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) { |
| 42 #if !defined(OS_NACL) | 41 #if !defined(OS_NACL) |
| 43 return priority == ThreadPriority::REALTIME_AUDIO && | 42 return priority == ThreadPriority::REALTIME_AUDIO && |
| 44 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0; | 43 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0; |
| 45 #else | 44 #else |
| 46 return false; | 45 return false; |
| 47 #endif | 46 #endif |
| 48 } | 47 } |
| 49 | 48 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 #if !defined(THREAD_SANITIZER) | 89 #if !defined(THREAD_SANITIZER) |
| 91 return 0; | 90 return 0; |
| 92 #else | 91 #else |
| 93 // ThreadSanitizer bloats the stack heavily. Evidence has been that the | 92 // ThreadSanitizer bloats the stack heavily. Evidence has been that the |
| 94 // default stack size isn't enough for some browser tests. | 93 // default stack size isn't enough for some browser tests. |
| 95 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). | 94 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). |
| 96 #endif | 95 #endif |
| 97 } | 96 } |
| 98 | 97 |
| 99 } // namespace base | 98 } // namespace base |
| OLD | NEW |