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

Side by Side Diff: base/threading/platform_thread_freebsd.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 28 matching lines...) Expand all
39 bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle, 39 bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle,
40 ThreadPriority priority) { 40 ThreadPriority priority) {
41 #if !defined(OS_NACL) 41 #if !defined(OS_NACL)
42 return priority == kThreadPriority_RealtimeAudio && 42 return priority == kThreadPriority_RealtimeAudio &&
43 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0; 43 pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0;
44 #else 44 #else
45 return false; 45 return false;
46 #endif 46 #endif
47 } 47 }
48 48
49 bool HandleGetThreadPriorityForPlatform(PlatformThreadHandle handle,
50 ThreadPriority* priority) {
51 #if !defined(OS_NACL)
52 // Mirrors HandleSetThreadPriorityForPlatform()'s implementation.
rvargas (doing something else) 2015/03/19 22:19:21 Do we need this comment?
gab 2015/03/30 20:14:45 I like it, if anything it answers your question be
rvargas (doing something else) 2015/03/30 22:31:22 It doesn't answer my question :p. I noticed you we
53 int maybe_sched_rr = 0;
54 struct sched_param maybe_realtime_prio = {0};
55 if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
rvargas (doing something else) 2015/03/19 22:19:21 why self() and not handle?
gab 2015/03/30 20:14:45 Because it mirrors HandleSetThreadPriorityForPlatf
rvargas (doing something else) 2015/03/30 22:31:22 I don't think that's a strong enough justification
gab 2015/03/31 14:02:33 Added a TODO, will find an owner once this lands.
56 &maybe_realtime_prio) == 0 &&
57 maybe_sched_rr == SCHED_RR &&
58 maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
59 *priority = kThreadPriority_RealtimeAudio;
60 return true;
61 }
62 #endif
63 return false;
64 }
65
49 } // namespace internal 66 } // namespace internal
50 67
51 // static 68 // static
52 void PlatformThread::SetName(const char* name) { 69 void PlatformThread::SetName(const char* name) {
53 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); 70 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
54 tracked_objects::ThreadData::InitializeThreadContext(name); 71 tracked_objects::ThreadData::InitializeThreadContext(name);
55 72
56 #if !defined(OS_NACL) 73 #if !defined(OS_NACL)
57 // On FreeBSD we can get the thread names to show up in the debugger by 74 // On FreeBSD we can get the thread names to show up in the debugger by
58 // setting the process name for the LWP. We don't want to do this for the 75 // setting the process name for the LWP. We don't want to do this for the
(...skipping 15 matching lines...) Expand all
74 #if !defined(THREAD_SANITIZER) 91 #if !defined(THREAD_SANITIZER)
75 return 0; 92 return 0;
76 #else 93 #else
77 // ThreadSanitizer bloats the stack heavily. Evidence has been that the 94 // ThreadSanitizer bloats the stack heavily. Evidence has been that the
78 // default stack size isn't enough for some browser tests. 95 // default stack size isn't enough for some browser tests.
79 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux). 96 return 2 * (1 << 23); // 2 times 8192K (the default stack size on Linux).
80 #endif 97 #endif
81 } 98 }
82 99
83 } // namespace base 100 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698