mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Change the semantics of proc_nice() for Windows to better match the values of the wmic output
This commit is contained in:
parent
64945e9387
commit
5c169af7c9
1 changed files with 18 additions and 12 deletions
30
win32/nice.c
30
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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue