setpriority() equivalent in Solaris2

setpriority() equivalent in Solaris2

Post by Leif Hedstr » Fri, 16 Sep 1994 05:39:29



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! :)

Thanks,

-- Leif

 
 
 

setpriority() equivalent in Solaris2

Post by William LeFebv » Fri, 16 Sep 1994 23:39:09




>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


 
 
 

setpriority() equivalent in Solaris2

Post by William LeFebv » Wed, 28 Sep 1994 01:32:51




>Where can I find definitions for PRIO_MIN and PRIO_MAX?   They exist
>in resource.h under 4.1.3, but I don't see them anywhere in Sol 2.x.
>Or are these supposed to be user-defined?

Sorry.  I see that they are defined explicitly in the code at the
top.  Not sure which include file is supposed to define them, but
they are defined in sunos5 top as follows:

#ifndef PRIO_MIN
#define PRIO_MIN        -20
#endif
#ifndef PRIO_MAX
#define PRIO_MAX        20
#endif

Quote:>Also, what is the purpose of the tsparms and scale variables?  They
>are assigned to, but never referenced.

Huh?  The following line (straight out of the posting) references both:

Quote:>>  tsparms->ts_uprilim = tsparms->ts_upri = -(scale * prio) / 20;

The tsparms structure is part of the pcparms structure which is passed
to priocntl as the fourth argument.

                        William LeFebvre
                        Decision and Information Sciences
                        Argonne National Laboratory

 
 
 

1. Solaris equivalent to SunOS getpriority/setpriority

Does DVR4/Solaris have an equivalent for the above SunOS library functions?

Thanks,
James
---
.........................................................................
 James Drenter               \\    Everywhere is walking distance       \\


    http://diogenes.cs.clemson.edu/~roofus/roofus.html \\       Wright     \\
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. Rio500 in KDE?

3. Solaris2.3's equivalent of /etc/master.d/kernel

4. How do I setup Linux as a POP3 server?

5. Remote Mounting CDROM from one SOLARIS2.4 BOX to other SOLARIS2.4 BOX

6. Compaq Fibre Array controller

7. Solaris2.6 TCP/IP faces Solaris2.5.1.

8. Serial to TCP

9. Installing sed3.0 and Solaris2.4 vs sed3.0 and Solaris2.5

10. How I can mount CD Solaris2.0 Answer Book in Solaris2.5

11. Losing space from Solaris2.4 to Solaris2.5.1?

12. Fun Upgrading Solaris2.1 to Solaris2.3

13. Does anyone have ssh binaries for Solaris2.5.1 or Solaris2.6?