com php-src: Change the semantics of proc_nice() for Windows to better match the values of the wmic output: win32/nice.c
| From: | Kalle Sommer Nielsen | Date: | Sun, 16 Oct 2016 03:21:30 +0000 |
| Subject: | com php-src: Change the semantics of proc_nice() for Windows to better match the values of the wmic output: win32/nice.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95113@lists.php.net to get a copy of this message | ||
Commit: 5c169af7c9f5761810cac84fe402ef3e9e79168c
Author: Kalle Sommer Nielsen <kalle@php.net> Sun, 16 Oct 2016 05:21:30 +0200
Parents: 64945e9387e415fe38c05d7e483ad2d075567336
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5c169af7c9f5761810cac84fe402ef3e9e79168c
Log:
Change the semantics of proc_nice() for Windows to better match the values of the wmic output
Changed paths:
M win32/nice.c
Diff:
diff --git a/win32/nice.c b/win32/nice.c
index 2b66a46..4a83faf 100644
--- a/win32/nice.c
+++ b/win32/nice.c
@@ -30,19 +30,25 @@
* +-----------------------+-----------------------------+
* | Expression | Priority type |
* +-----------------------+-----------------------------+
- * | priority > 5 | REALTIME_PRIORITY_CLASS |
+ * | priority > 23 | REALTIME_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
- * | priority == 5 | HIGH_PRIORITY_CLASS |
+ * | priority > 12 | HIGH_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
- * | priority > 0 | ABOVE_NORMAL_PRIORITY_CLASS |
+ * | priority > 9 | ABOVE_NORMAL_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
- * | priority == 0 | NORMAL_PRIORITY_CLASS |
+ * | priority > 7 | NORMAL_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
- * | priority < -5 | BELOW_NORMAL_PRIORITY_CLASS |
+ * | priority > 5 | IDLE_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
- * | priority < -10 | IDLE_PRIORITY_CLASS |
+ * | priority > 3 | BELOW_NORMAL_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
*
+ * Note, these values tries to mimic the outpof of wmic.
+ *
+ * If the value is below 4, then the process priority will default to
+ * NORMAL_PRIORITY_CLASS and anything above 23 will always be
+ * REALTIME_PRIORITY_CLASS.
+ *
* This is applied to the main process, not per thread, although this could
* be implemented using SetThreadPriority() at one point.
*/
@@ -51,16 +57,16 @@ PHPAPI int nice(zend_long p)
{
DWORD dwFlag = NORMAL_PRIORITY_CLASS;
- if (p > 5) {
+ if (p > 23) {
dwFlag = REALTIME_PRIORITY_CLASS;
- } else if (p == 5) {
+ } else if (p > 12) {
dwFlag = HIGH_PRIORITY_CLASS;
- } else if (p > 0) {
+ } else if (p > 9) {
dwFlag = ABOVE_NORMAL_PRIORITY_CLASS;
- } else if (p < 0 && p < -5) {
- dwFlag = BELOW_NORMAL_PRIORITY_CLASS;
- } else if (p < -10) {
+ } else if (p > 5 && p < 7) {
dwFlag = IDLE_PRIORITY_CLASS;
+ } else if (p > 3 && p < 7) {
+ dwFlag = BELOW_NORMAL_PRIORITY_CLASS;
}
if (!SetPriorityClass(GetCurrentProcess(), dwFlag)) {