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

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

Issue 1006933003: Add full SetThreadPriority support to Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 29 matching lines...) Expand all
40 bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle, 40 bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle,
41 ThreadPriority priority) { 41 ThreadPriority priority) {
42 #if !defined(OS_NACL) 42 #if !defined(OS_NACL)
43 return priority == kThreadPriority_RealtimeAudio && 43 return priority == kThreadPriority_RealtimeAudio &&
44 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0; 44 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0;
45 #else 45 #else
46 return false; 46 return false;
47 #endif 47 #endif
48 } 48 }
49 49
50 bool HandleGetThreadPriorityForPlatform(PlatformThreadHandle handle,
51 ThreadPriority* priority) {
52 #if !defined(OS_NACL)
53 // Mirrors HandleSetThreadPriorityForPlatform()'s implementation.
54 int maybe_sched_rr = 0;
55 struct sched_param maybe_realtime_prio = {0};
56 if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
57 &maybe_realtime_prio) == 0 &&
58 maybe_sched_rr == SCHED_RR &&
59 maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
60 *priority = kThreadPriority_RealtimeAudio;
61 return true;
62 }
63 #endif
64 return false;
65 }
66
50 } // namespace internal 67 } // namespace internal
51 68
52 // static 69 // static
53 void PlatformThread::SetName(const char* name) { 70 void PlatformThread::SetName(const char* name) {
54 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); 71 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
55 tracked_objects::ThreadData::InitializeThreadContext(name); 72 tracked_objects::ThreadData::InitializeThreadContext(name);
56 73
57 #if !defined(OS_NACL) 74 #if !defined(OS_NACL)
58 // On linux we can get the thread names to show up in the debugger by setting 75 // 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 76 // 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) 101 #if !defined(THREAD_SANITIZER)
85 return 0; 102 return 0;
86 #else 103 #else
87 // ThreadSanitizer bloats the stack heavily. Evidence has been that the 104 // ThreadSanitizer bloats the stack heavily. Evidence has been that the
88 // default stack size isn't enough for some browser tests. 105 // default stack size isn't enough for some browser tests.
89 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). 106 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux).
90 #endif 107 #endif
91 } 108 }
92 109
93 } // namespace base 110 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698