Hello,

It's necessary for me to change the priority of my application's process from 
the code.
I try to use the nice() function to set the priority and priocntl() to read the 
current process' priority, but I get priority=0 before the nice() and 
priority=19 after the nice() without respect to the argument I pass to nice(). 
What do I do wrong? 

int GetPriority(void) 
{ 
pcnice_t niceSet; 
int rc; 

niceSet.pc_op = PC_GETNICE; 
if(-1 == priocntl(P_PID, getpid(), PC_DONICE, &niceSet)) 
rc = -1; 
else 
rc = niceSet.pc_val; 

return rc; 
} 

int main() 
{ 
int newPriority, currentPriority; 

newPriority = 27; 

currentPriority = GetPriority(); 
printf("default priority = %d\n", currentPriority); 

nice(newPriority); 

currentPriority = GetPriority(); 
printf("new priority = %d\n", currentPriority); 

return 0; 
}
-- 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to