libc/sched: Map the nice value more correctly
from https://pubs.opengroup.org/onlinepubs/007904875/functions/setpriority.html: 1.The nice value shall in the range [-{NZERO},{NZERO} -1] 2.Lower nice value shall cause more favorable scheduling Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I5ad60d92abc3b69fbaa406da68cec2e40ca3fa6d
This commit is contained in:
parent
fe992a5b6c
commit
3d0320f891
|
@ -276,10 +276,10 @@
|
||||||
#define NL_TEXTMAX _POSIX2_LINE_MAX
|
#define NL_TEXTMAX _POSIX2_LINE_MAX
|
||||||
|
|
||||||
/* NZERO
|
/* NZERO
|
||||||
* Default process priority. Minimum Acceptable Value: 20
|
* Default process priority. Minimum Acceptable Value: 128
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NZERO 20
|
#define NZERO 128
|
||||||
|
|
||||||
/* Required for asynchronous I/O */
|
/* Required for asynchronous I/O */
|
||||||
|
|
||||||
|
|
|
@ -82,5 +82,9 @@ int getpriority(int which, id_t who)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return param.sched_priority;
|
/* Since -1 is a legal return value, clear errno to avoid the chaos */
|
||||||
|
|
||||||
|
set_errno(0);
|
||||||
|
|
||||||
|
return NZERO - param.sched_priority;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ int setpriority(int which, id_t who, int value)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
param.sched_priority = value;
|
param.sched_priority = NZERO - value;
|
||||||
|
|
||||||
return sched_setparam(who, ¶m);
|
return sched_setparam(who, ¶m);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue