diff options
-rw-r--r-- | ext/standard/tests/general_functions/proc_nice_basic-win.phpt | 22 | ||||
-rw-r--r-- | win32/nice.c | 29 |
2 files changed, 24 insertions, 27 deletions
diff --git a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt index 45d7c9245e..232389fd90 100644 --- a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt +++ b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt @@ -71,12 +71,12 @@ function get_priority_from_wmic() { $p = [ /* '<verbose name>' => ['<wmic value>', '<proc_nice value>'] */ - 'Idle' => [6, -10], - 'Below normal' => [4, -3], + 'Idle' => [4, 10], + 'Below normal' => [6, 5], 'Normal' => [8, 0], - 'Above normal' => [10, 4], - 'High priority' => [13, 5], - 'Real time' => [24, 8] + 'Above normal' => [10, -5], + 'High priority' => [13, -10], + 'Real time' => [24, -16] ]; foreach ($p as $test => $data) { @@ -84,13 +84,13 @@ foreach ($p as $test => $data) { proc_nice($data[1]); - print (get_priority_from_wmic() === $data[0] ? 'Passed' : 'Failed') . PHP_EOL; + print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; } ?> --EXPECTF-- -Testing 'Idle' (-10): Passed -Testing 'Below normal' (-3): Passed +Testing 'Idle' (10): Passed +Testing 'Below normal' (5): Passed Testing 'Normal' (0): Passed -Testing 'Above normal' (4): Passed -Testing 'High priority' (5): Passed -Testing 'Real time' (8): Passed +Testing 'Above normal' (-5): Passed +Testing 'High priority' (-10): Passed +Testing 'Real time' (-16): Passed diff --git a/win32/nice.c b/win32/nice.c index 4a83faf78e..db26cc1aa6 100644 --- a/win32/nice.c +++ b/win32/nice.c @@ -30,24 +30,21 @@ * +-----------------------+-----------------------------+ * | Expression | Priority type | * +-----------------------+-----------------------------+ - * | priority > 23 | REALTIME_PRIORITY_CLASS | + * | priority < -14 | REALTIME_PRIORITY_CLASS | * +-----------------------+-----------------------------+ - * | priority > 12 | HIGH_PRIORITY_CLASS | + * | priority < -9 | HIGH_PRIORITY_CLASS | * +-----------------------+-----------------------------+ - * | priority > 9 | ABOVE_NORMAL_PRIORITY_CLASS | + * | priority < -4 | ABOVE_NORMAL_PRIORITY_CLASS | * +-----------------------+-----------------------------+ - * | priority > 7 | NORMAL_PRIORITY_CLASS | + * | priority > 4 | BELOW_NORMAL_PRIORITY_CLASS | * +-----------------------+-----------------------------+ - * | priority > 5 | IDLE_PRIORITY_CLASS | - * +-----------------------+-----------------------------+ - * | priority > 3 | BELOW_NORMAL_PRIORITY_CLASS | + * | priority > 9 | IDLE_PRIORITY_CLASS | * +-----------------------+-----------------------------+ * - * Note, these values tries to mimic the outpof of wmic. + * If a value is between -4 and 4 (inclusive), then the priority will be set + * to NORMAL_PRIORITY_CLASS. * - * 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. + * These values tries to mimic that of the UNIX version of nice(). * * This is applied to the main process, not per thread, although this could * be implemented using SetThreadPriority() at one point. @@ -57,15 +54,15 @@ PHPAPI int nice(zend_long p) { DWORD dwFlag = NORMAL_PRIORITY_CLASS; - if (p > 23) { + if (p < -14) { dwFlag = REALTIME_PRIORITY_CLASS; - } else if (p > 12) { + } else if (p < -9) { dwFlag = HIGH_PRIORITY_CLASS; - } else if (p > 9) { + } else if (p < -4) { dwFlag = ABOVE_NORMAL_PRIORITY_CLASS; - } else if (p > 5 && p < 7) { + } else if (p > 9) { dwFlag = IDLE_PRIORITY_CLASS; - } else if (p > 3 && p < 7) { + } else if (p > 4) { dwFlag = BELOW_NORMAL_PRIORITY_CLASS; } |