From 3c85635de170f71243658b69d9dff6cd8285c77d Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 27 May 2015 12:50:55 -0700 Subject: [PATCH] Add SetLowPriorityProcess to utils and use it in dEQP support This provides a cross-platform way to make sure dEQP runs in a low priority process. BUG=angleproject:892 Change-Id: I0d12f1eacb78be43edcdb6622f945734c0b377ff Reviewed-on: https://chromium-review.googlesource.com/273595 Reviewed-by: Jamie Madill Tested-by: Corentin Wallez --- src/tests/deqp.gypi | 2 ++ src/tests/deqp_support/tcuANGLEWin32Platform.cpp | 5 ++--- src/tests/deqp_support/tcuANGLEWin32Platform.h | 1 - util/linux/Linux_system_utils.cpp | 8 ++++++++ util/system_utils.h | 2 ++ util/win32/Win32_system_utils.cpp | 5 +++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/tests/deqp.gypi b/src/tests/deqp.gypi index 12e763d3c..db7bac530 100644 --- a/src/tests/deqp.gypi +++ b/src/tests/deqp.gypi @@ -1056,6 +1056,7 @@ 'dependencies': [ 'angle_deqp_libtester', + '<(angle_path)/util/util.gyp:angle_util', ], 'defines': [ @@ -1075,6 +1076,7 @@ 'dependencies': [ 'angle_deqp_libtester', + '<(angle_path)/util/util.gyp:angle_util', ], 'defines': [ diff --git a/src/tests/deqp_support/tcuANGLEWin32Platform.cpp b/src/tests/deqp_support/tcuANGLEWin32Platform.cpp index 2b1884105..1c1263bb4 100644 --- a/src/tests/deqp_support/tcuANGLEWin32Platform.cpp +++ b/src/tests/deqp_support/tcuANGLEWin32Platform.cpp @@ -24,6 +24,7 @@ #include #include "egluGLContextFactory.hpp" +#include "system_utils.h" #include "tcuANGLEWin32NativeDisplayFactory.h" #include "tcuNullContextFactory.hpp" @@ -32,9 +33,7 @@ namespace tcu ANGLEWin32Platform::ANGLEWin32Platform() { - // Set process priority to lower. - // TODO(cwallez): add this to utils - SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); + angle::SetLowPriorityProcess(); #if defined(ANGLE_DEQP_GLES2_TESTS) || defined(ANGLE_DEQP_GLES3_TESTS) std::vector d3d11Attribs; diff --git a/src/tests/deqp_support/tcuANGLEWin32Platform.h b/src/tests/deqp_support/tcuANGLEWin32Platform.h index a1f4745f0..7cbf33979 100644 --- a/src/tests/deqp_support/tcuANGLEWin32Platform.h +++ b/src/tests/deqp_support/tcuANGLEWin32Platform.h @@ -24,7 +24,6 @@ #include "tcuDefs.hpp" #include "tcuPlatform.hpp" #include "gluPlatform.hpp" -#include "tcuWin32API.h" #ifndef _EGLUPLATFORM_HPP # include "egluPlatform.hpp" diff --git a/util/linux/Linux_system_utils.cpp b/util/linux/Linux_system_utils.cpp index 697cae577..13a10d853 100644 --- a/util/linux/Linux_system_utils.cpp +++ b/util/linux/Linux_system_utils.cpp @@ -8,7 +8,10 @@ #include "system_utils.h" +#include #include +#include +#include #include #include @@ -38,4 +41,9 @@ std::string GetExecutableDirectory() return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; } +void SetLowPriorityProcess() +{ + setpriority(PRIO_PROCESS, getpid(), 10); +} + } // namespace angle diff --git a/util/system_utils.h b/util/system_utils.h index 6ae431457..1820b444e 100644 --- a/util/system_utils.h +++ b/util/system_utils.h @@ -20,6 +20,8 @@ std::string GetExecutableDirectory(); // Cross platform equivalent of the Windows Sleep function void Sleep(unsigned int milliseconds); +void SetLowPriorityProcess(); + } // namespace angle #endif // SAMPLE_UTIL_PATH_UTILS_H diff --git a/util/win32/Win32_system_utils.cpp b/util/win32/Win32_system_utils.cpp index 99d1a26b5..f33479c93 100644 --- a/util/win32/Win32_system_utils.cpp +++ b/util/win32/Win32_system_utils.cpp @@ -33,4 +33,9 @@ void Sleep(unsigned int milliseconds) ::Sleep(static_cast(milliseconds)); } +void SetLowPriorityProcess() +{ + SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); +} + } // namespace angle