[prev in list] [next in list] [prev in thread] [next in thread]
List: opensolaris-code
Subject: [osol-code] setting process priority with nice() command
From: "Alex B." <box2go () gmail ! com>
Date: 2011-03-07 4:09:30
Message-ID: 152768880.401299499808466.JavaMail.Twebapp () sf-app1
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic