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

Unified Diff: base/threading/platform_thread_linux.cc

Issue 15203009: posix thread: Attempt to set audio threads to real time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: braces for if. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_linux.cc
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc
index 42e12c71a554920d94c23c503ff02c80bf8aaad4..8556431a36a9b2826a42e96213d4b278b776ba54 100644
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -76,6 +76,24 @@ void PlatformThread::SetName(const char* name) {
void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
ThreadPriority priority) {
#ifndef OS_NACL
jar (doing other things) 2013/05/29 02:07:04 nit: To make this a bit more readable, how about:
dgreid 2013/05/29 18:52:34 agreed, it would be better, but it won't compile,
jar (doing other things) 2013/05/30 18:15:25 OK... Please add comments after each #endif to ind
dgreid 2013/05/30 18:59:22 Done.
+ if (priority == kThreadPriority_RealtimeAudio) {
+ const int kRealTimePrio = 8;
+
+ struct sched_param sched_param;
+ memset(&sched_param, 0, sizeof(sched_param));
+ sched_param.sched_priority = kRealTimePrio;
+
+ if (pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param) == 0) {
+ // Got real time priority, no need to set nice level.
+ return;
+ }
+
+ LOG(INFO) << "Failed to set audio thread to real time.";
jar (doing other things) 2013/05/29 02:07:04 We've tended to avoid doing LOG() in favor of DLOG
dgreid 2013/05/29 18:52:34 I'm OK removing this, it's probably not worth the
jar (doing other things) 2013/05/30 18:15:25 WFM
dgreid 2013/05/30 18:59:22 Great, I've also found a way to test that this and
+#if defined(OS_CHROMEOS)
+ return; // RT prio should always work on ChromeOS. Never set nice level.
jar (doing other things) 2013/05/29 02:07:04 This seems strange. Are you saying the request sh
dgreid 2013/05/29 18:52:34 On linux the request will fail unless the user has
jar (doing other things) 2013/05/30 18:15:25 If you think it will never run... less code seems
+#endif
+ }
+
// setpriority(2) will set a thread's priority if it is passed a tid as
// the 'process identifier', not affecting the rest of the threads in the
// process. Setting this priority will only succeed if the user has been
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698