#include <sys/time.h>
|
#include <sys/resource.h>
|
int
getpriority (int which, int who); |
int
setpriority (int which, int who, int prio); |
The setpriority returns 0 on success and -1 on error with the errno set.
If the prio is greater than the greatest priority supported, it is set to the greatest priority supported. If the prio is lesser than the least priority supported, it is set to the least priority supported.
#include<sys/resource.h> #include<unistd.h> #include<stdio.h> int test_getpriority() { int retVal; errno = 0; retVal = getpriority(PRIO_PROCESS, 0); if((retVal == -1) && (errno == ENOSYS)) { printf("Failed"); return -1; } else { printf("getpriority passed"); printf("\npriority = %d ", retVal); } return 0; }
Output
getpriority passed priority = 0
#include<sys/resource.h> #include<unistd.h> #include<stdio.h> int test_setpriority() { int retVal; errno = 0; retVal = setpriority(PRIO_PROCESS, 0, 0); if((retVal == -1) && (errno == ENOSYS)) { printf(“Failed”); return -1; } else { printf("Setpriority passed"); printf("\n getpriority now: %d", getpriority(PRIO_PROCESS,0)) } return 0; }
Output
Setpriority passed getpriority now: 0
1. The values PRIO_PGRP and PRIO_USER for the which and any value other than 0 for who are not supported, when given return ENOSYS.
2. To effectively increase or decrease the priority of the process, one should consider the following:
Highest -16 to -20
Above Normal -6 to -15
Normal +4 to -5
Below Normal +14 to +5
Lowest +20 to +15
3. The setting of the priority to values -16 to -20 is not supported, the use of which sets errno to EINVAL.
[ENOSYS] -> The which argument was one of PRIO_PGRP, or PRIO_USER. and/or who was other than 0.
[EINVAL] ->The process tried to set the priority to a value from among -16 to -20.
© 2005-2007 Nokia |