Files
system-programming/chp6/nice.c
2025-07-05 16:02:58 +02:00

20 lines
457 B
C

#include <stdio.h>
#include <sys/resource.h>
#include <unistd.h>
int main(void)
{
int ret;
ret = nice(0);
printf("Current nice by nice function: %d\n", ret);
ret = getpriority(PRIO_PROCESS, 0);
printf("Current nice by getpriority function: %d\n", ret);
if (setpriority(PRIO_PROCESS, 0, 10) == -1) {
perror("setpriority");
return -1;
}
ret = getpriority(PRIO_PROCESS, 0);
printf("Current nice by getpriority function: %d\n", ret);
return 0;
}