summaryrefslogtreecommitdiff
path: root/win32/nice.c
diff options
context:
space:
mode:
authorKalle Sommer Nielsen <kalle@php.net>2016-10-18 23:25:59 +0200
committerKalle Sommer Nielsen <kalle@php.net>2016-10-18 23:25:59 +0200
commitd0a3f2e46d49ba7d14ce900012b2424e49693d93 (patch)
tree389fdd4acff885ee0691dc189ea8b6ca0b1c1ba1 /win32/nice.c
parente2b52c510effa0eaf58fb544f8a09b1e7121ec1f (diff)
downloadphp-git-d0a3f2e46d49ba7d14ce900012b2424e49693d93.tar.gz
Make proc_nice() more in line with that of Unix, as discussed with Anatol
Diffstat (limited to 'win32/nice.c')
-rw-r--r--win32/nice.c29
1 files changed, 13 insertions, 16 deletions
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;
}