com php-src: Make proc_nice() more in line with that of Unix, as discussed with Anatol: ex t/standard/tests/general_functions/proc_nice_basic-win.
phpt win32/nice.c

From: Date: Tue, 18 Oct 2016 21:25:59 +0000
Subject: com php-src: Make proc_nice() more in line with that of Unix, as discussed with Anatol: ex t/standard/tests/general_functions/proc_nice_basic-win.
phpt win32/nice.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95213@lists.php.net to get a copy of this message
Commit: d0a3f2e46d49ba7d14ce900012b2424e49693d93 Author: Kalle Sommer Nielsen <kalle@php.net> Tue, 18 Oct 2016 23:25:59 +0200 Parents: e2b52c510effa0eaf58fb544f8a09b1e7121ec1f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d0a3f2e46d49ba7d14ce900012b2424e49693d93 Log: Make proc_nice() more in line with that of Unix, as discussed with Anatol Changed paths: M ext/standard/tests/general_functions/proc_nice_basic-win.phpt M win32/nice.c Diff: 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 45d7c92..232389f 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 4a83faf..db26cc1 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; }

« previous php.cvs (#95213) next »