#include <unistd.h>
|
int
nice (int incr); |
The nice function obtains the scheduling priority of the process from the system and sets it to the priority value specified in incr. The priority is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling.
#include<unistd.h> #include<stdio.h> int test_nice() { int retVal; errno = 0; int i = -10; int ret_get1 = getpriority(PRIO_PROCESS,0); retVal = nice(i); int ret_get2 = getpriority(PRIO_PROCESS,0); if((retVal == -1)&&(errno)) { printf("failed"); return -1; } else { if(!(i - (ret_get2 – retget1))) printf("Nice value: %d\n", i) printf("nice passed"); } return 0; }
Output
Nice value: -10 nice passed
© 2005-2007 Nokia |