summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win32/nice.c30
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)) {