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

Unified Diff: base/threading/platform_thread_posix.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: 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_posix.cc
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 43e58b73375a0c3273422d9c28e10150d3835197..a4d23cfe0afe825882dc94fc727dab741a10df0a 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -48,6 +48,18 @@ struct ThreadParams {
ThreadPriority priority;
};
+#if defined(OS_LINUX)
+static int SetCurrentThreadRealTime() {
+ const int kRealTimePrio = 8;
+
+ struct sched_param sched_param;
+ memset(&sched_param, 0, sizeof(sched_param));
+ sched_param.sched_priority = kRealTimePrio;
+
+ return pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param);
+}
+#endif
+
void SetCurrentThreadPriority(ThreadPriority priority) {
#if defined(OS_LINUX) || defined(OS_ANDROID)
switch (priority) {
@@ -56,6 +68,11 @@ void SetCurrentThreadPriority(ThreadPriority priority) {
break;
case kThreadPriority_RealtimeAudio:
#if defined(OS_LINUX)
DaveMoore 2013/05/23 17:20:16 If we're doing something different on OS_CHROMEOS
dgreid 2013/05/23 17:24:47 This change stops switching the niceness of the th
DaveMoore 2013/05/23 18:21:12 Then I think we should explicitly avoid ever setti
dgreid 2013/05/23 18:36:28 We still want to set the nice level if it is posit
DaveMoore 2013/05/23 20:16:31 It's at best misleading, and at worst will lead to
dgreid 2013/05/23 20:37:49 Thanks Dave, Not sure about the consequences of t
+ if (SetCurrentThreadRealTime() == 0)
+ // Got real time priority.
+ return;
+
+ // Otherwise try to set an advantageous nice level.
const int kNiceSetting = -10;
// Linux isn't posix compliant with setpriority(2), it will set a thread
// priority if it is passed a tid, not affecting the rest of the threads
« 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