Commit 69026f1c authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

[base] Support ::GetThreadPriority() returning 3.

We have observed ::GetThreadPriority returning 3 after the thread
priority is set to NORMAL on Windows 7. This CL adds code to
correctly map 3 to ThreadPriority::NORMAL in
PlatformThread::GetCurrentThreadPriority(). From documentation,
that should only happen in a REALTIME_PRIORITY_CLASS process,
but since we can't get the thread and process priority atomically,
we can hardly add a robust DCHECK for that.

Bug: 1014659, 872820
Change-Id: If43b9d46fd766dd1d22e0efaeafe0b738ee57d4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898209
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712564}
parent f9827d67
......@@ -33,6 +33,10 @@ namespace {
// thread mode is enabled on Windows 7.
constexpr int kWin7BackgroundThreadModePriority = 4;
// Value sometimes returned by ::GetThreadPriority() after thread priority is
// set to normal on Windows 7.
constexpr int kWin7NormalPriority = 3;
// The information on how to set the thread name comes from
// a MSDN article: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD kVCThreadNameException = 0x406D1388;
......@@ -441,6 +445,9 @@ ThreadPriority PlatformThread::GetCurrentThreadPriority() {
case kWin7BackgroundThreadModePriority:
DCHECK_EQ(win::GetVersion(), win::Version::WIN7);
return ThreadPriority::BACKGROUND;
case kWin7NormalPriority:
DCHECK_EQ(win::GetVersion(), win::Version::WIN7);
FALLTHROUGH;
case THREAD_PRIORITY_NORMAL:
return ThreadPriority::NORMAL;
case THREAD_PRIORITY_ABOVE_NORMAL:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment