>Hi,
>I hope this isn't an FAQ... Exactly how do I use priocntl() in Solaris2
>to "mimic" the behaviour of setpriority()?
>truss'ing a test program indicates that I should do something like
> priocntl(P_PID, aaa, PC_GETPARMS, (caddr_t)&bbb);
> .
> .
> .
> priocntl(P_PID, aaa, PC_GETCID, (caddr_t)&ccc);
> .
> .
> .
> priocntl(P_PID, ddd, PC_GETPARMS,( caddr_t)&bbb);
> .
> .
> .
>I haven't examined this a lot yet, I'm hoping someone already knows this,
>and can save me some time! :)
This is part of the setpriority faking routine that's in the sunos5
module for top.
This assumes that the first argument to setpriority is PRIO_PROCESS
and in actuality ignores that argument. Hope this helps. I don't
even remember who wrote this anymore: 6 different people have worked
on the sunos5 module thru the years.
--
int
setpriority (int dummy, int who, int niceval)
{
int scale;
int prio;
pcinfo_t pcinfo;
pcparms_t pcparms;
tsparms_t *tsparms;
strcpy (pcinfo.pc_clname, "TS");
if (priocntl (0, 0, PC_GETCID, (caddr_t) & pcinfo) == -1)
return (-1);
prio = niceval;
if (prio > PRIO_MAX)
prio = PRIO_MAX;
else if (prio < PRIO_MIN)
prio = PRIO_MIN;
tsparms = (tsparms_t *) pcparms.pc_clparms;
scale = ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri;
tsparms->ts_uprilim = tsparms->ts_upri = -(scale * prio) / 20;
pcparms.pc_cid = pcinfo.pc_cid;
if (priocntl (P_PID, who, PC_SETPARMS, (caddr_t) & pcparms) == -1)
return (-1);
return (0);
Quote:}
--
William LeFebvre
Decision and Information Sciences
Argonne National Laboratory