printf ("nice value is currently %d\n", nice (0));
往往,一個行程會想要設定一個絕對的友善值,而不是設定一個相對增加的友善值。如
下的程式碼可以完成此事:
int ret, val;
/* 取得當前的友善值 */
val = nice (0);
/* 我們想要設定 10 的友善值 */
val = 10 - val;
errno = 0;
ret = nice (val);
if ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.