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

Side by Side Diff: base/threading/platform_thread_linux.cc

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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 <sched.h> 8 #include <sched.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace internal { 25 namespace internal {
26 26
27 namespace { 27 namespace {
28 #if !defined(OS_NACL) 28 #if !defined(OS_NACL)
29 const struct sched_param kRealTimePrio = {8}; 29 const struct sched_param kRealTimePrio = {8};
30 #endif 30 #endif
31 } // namespace 31 } // namespace
32 32
33 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { 33 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
34 {kThreadPriority_RealtimeAudio, -10}, 34 {ThreadPriority::BACKGROUND, 10},
35 {kThreadPriority_Background, 10}, 35 {ThreadPriority::NORMAL, 0},
36 {kThreadPriority_Normal, 0}, 36 {ThreadPriority::DISPLAY, -6},
37 {kThreadPriority_Display, -6}, 37 {ThreadPriority::REALTIME_AUDIO, -10},
38 }; 38 };
39 39
40 bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle, 40 bool SetThreadPriorityForPlatform(PlatformThreadHandle handle,
41 ThreadPriority priority) { 41 ThreadPriority priority) {
42 #if !defined(OS_NACL) 42 #if !defined(OS_NACL)
43 return priority == kThreadPriority_RealtimeAudio && 43 // TODO(gab): Assess the correctness of using |pthread_self()| below instead
44 // of |handle|. http://crbug.com/468793.
45 return priority == ThreadPriority::REALTIME_AUDIO &&
44 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0; 46 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0;
45 #else 47 #else
46 return false; 48 return false;
47 #endif 49 #endif
48 } 50 }
49 51
52 bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
53 ThreadPriority* priority) {
54 #if !defined(OS_NACL)
55 int maybe_sched_rr = 0;
56 struct sched_param maybe_realtime_prio = {0};
57 // TODO(gab): Assess the correctness of using |pthread_self()| below instead
58 // of |handle|. http://crbug.com/468793.
59 if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
60 &maybe_realtime_prio) == 0 &&
61 maybe_sched_rr == SCHED_RR &&
62 maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
63 *priority = ThreadPriority::REALTIME_AUDIO;
64 return true;
65 }
66 #endif
67 return false;
68 }
69
50 } // namespace internal 70 } // namespace internal
51 71
52 // static 72 // static
53 void PlatformThread::SetName(const char* name) { 73 void PlatformThread::SetName(const char* name) {
54 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); 74 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
55 tracked_objects::ThreadData::InitializeThreadContext(name); 75 tracked_objects::ThreadData::InitializeThreadContext(name);
56 76
57 #if !defined(OS_NACL) 77 #if !defined(OS_NACL)
58 // On linux we can get the thread names to show up in the debugger by setting 78 // On linux we can get the thread names to show up in the debugger by setting
59 // the process name for the LWP. We don't want to do this for the main 79 // the process name for the LWP. We don't want to do this for the main
(...skipping 24 matching lines...) Expand all
84 #if !defined(THREAD_SANITIZER) 104 #if !defined(THREAD_SANITIZER)
85 return 0; 105 return 0;
86 #else 106 #else
87 // ThreadSanitizer bloats the stack heavily. Evidence has been that the 107 // ThreadSanitizer bloats the stack heavily. Evidence has been that the
88 // default stack size isn't enough for some browser tests. 108 // default stack size isn't enough for some browser tests.
89 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). 109 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux).
90 #endif 110 #endif
91 } 111 }
92 112
93 } // namespace base 113 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698