Chromium Code Reviews| 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 |