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

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

Issue 434803003: Linux, Android: fix call to setpriority(2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ThreadPriority priority) { 75 ThreadPriority priority) {
76 #if !defined(OS_NACL) 76 #if !defined(OS_NACL)
77 if (priority == kThreadPriority_RealtimeAudio) { 77 if (priority == kThreadPriority_RealtimeAudio) {
78 const struct sched_param kRealTimePrio = { 8 }; 78 const struct sched_param kRealTimePrio = { 8 };
79 if (pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0) { 79 if (pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0) {
80 // Got real time priority, no need to set nice level. 80 // Got real time priority, no need to set nice level.
81 return; 81 return;
82 } 82 }
83 } 83 }
84 84
85 // setpriority(2) will set a thread's priority if it is passed a tid as 85 // setpriority(2) should change the whole thread group's (i.e. process)
86 // the 'process identifier', not affecting the rest of the threads in the 86 // priority. However, on Linux it will only change the current thread. See
87 // process. Setting this priority will only succeed if the user has been 87 // the BUGs section in
88 // granted permission to adjust nice values on the system. 88 // http://man7.org/linux/man-pages/man2/getpriority.2.html.
89 DCHECK_NE(handle.id_, kInvalidThreadId); 89 DCHECK_NE(handle.id_, kInvalidThreadId);
90 const int kNiceSetting = ThreadNiceValue(priority); 90 const int kNiceSetting = ThreadNiceValue(priority);
91 if (setpriority(PRIO_PROCESS, handle.id_, kNiceSetting)) { 91 if (setpriority(PRIO_PROCESS, 0, kNiceSetting)) {
92 DVPLOG(1) << "Failed to set nice value of thread (" 92 DVPLOG(1) << "Failed to set nice value of thread ("
93 << handle.id_ << ") to " << kNiceSetting; 93 << handle.id_ << ") to " << kNiceSetting;
94 } 94 }
95 #endif // !defined(OS_NACL) 95 #endif // !defined(OS_NACL)
96 } 96 }
97 97
98 void InitThreading() {} 98 void InitThreading() {}
99 99
100 void InitOnThread() {} 100 void InitOnThread() {}
101 101
102 void TerminateOnThread() {} 102 void TerminateOnThread() {}
103 103
104 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { 104 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
105 #if !defined(THREAD_SANITIZER) && !defined(MEMORY_SANITIZER) 105 #if !defined(THREAD_SANITIZER) && !defined(MEMORY_SANITIZER)
106 return 0; 106 return 0;
107 #else 107 #else
108 // ThreadSanitizer bloats the stack heavily. Evidence has been that the 108 // ThreadSanitizer bloats the stack heavily. Evidence has been that the
109 // default stack size isn't enough for some browser tests. 109 // default stack size isn't enough for some browser tests.
110 // MemorySanitizer needs this as a temporary fix for http://crbug.com/353687 110 // MemorySanitizer needs this as a temporary fix for http://crbug.com/353687
111 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). 111 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux).
112 #endif 112 #endif
113 } 113 }
114 114
115 } // namespace base 115 } // namespace base
OLDNEW
« base/threading/platform_thread_android.cc ('K') | « base/threading/platform_thread_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698