Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getpriority() usage

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
Hi all,
my brain hurts once again..I might be boring the forum by asking too many questions on priority..Actually i am using a getpriority(which,who) function to get the scheduling priority in a C application in LINUX.

i am using the following way

getpriority(getpid(),0);

this function usually has to return either ESRCH or EINVAL i am actually looking for an answer ESRCH but this thing always return me EINVAL( which is invalid arguments)..

Can anybody help me in usage of this function..


thanks
logic4fun

P.S. ESRCH is No such process
 
From the manual
Code:
int getpriority(int which, int who);

Which  is  one  of  PRIO_PROCESS,
       PRIO_PGRP, or PRIO_USER,

So I would think
Code:
p = getpriority(PRIO_PROCESS,0);
Would be the thing to do
 
I tried using prio_process/prio_pgrp/prio_user but no matter what value i use..it always return me the ZERO..:(

Actually here is what i am planning to do..i am loading a cache with a particular instance and do some other processes and the program keeps running all the time. and the instance is passed through the command prompt.

ALL I wanted to do..is that If by accident someone tries to run the code with the same instance on the box it should Yell at me saying that it is already running. But as i said..if it is same instance only. with other instance it sure can Run.

For the above task earlier we used to use getpri(pid) and used to get the priority of the process and then proceed. but now getpri is not working anymore as we are migrating to LINUX...and when i went through the man pages getpriority(which,who) does the same thing with different arguments. but..i cant make it to work :-(

Any Ideas to perform above task.

thanks in advance
logic4fun

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top