diff options
author | Kalle Sommer Nielsen <kalle@php.net> | 2016-10-16 05:21:30 +0200 |
---|---|---|
committer | Kalle Sommer Nielsen <kalle@php.net> | 2016-10-16 05:21:30 +0200 |
commit | 5c169af7c9f5761810cac84fe402ef3e9e79168c (patch) | |
tree | f934cf753a36089eacf6eedb0b381a2d6812a850 /win32/nice.c | |
parent | 64945e9387e415fe38c05d7e483ad2d075567336 (diff) | |
download | php-git-5c169af7c9f5761810cac84fe402ef3e9e79168c.tar.gz |
Change the semantics of proc_nice() for Windows to better match the values of the wmic output
Diffstat (limited to 'win32/nice.c')
-rw-r--r-- | win32/nice.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/win32/nice.c b/win32/nice.c index 2b66a467ec..4a83faf78e 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)) { |