Process management

The priocntlset system call

   #include	<sys/types.h>
   #include	<sys/signal.h>
   #include	<sys/procset.h>
   #include	<sys/priocntl.h>
   #include	<sys/fppriocntl.h>
   #include	<sys/tspriocntl.h>

long priocntlset(procset_t *psp, int cmd, void *arg);

The priocntlset system call changes scheduler parameters of a set of processes or LWPs, just like priocntl. priocntlset has the same command set as priocntl; the cmd and arg input arguments are the same. But while priocntl applies to a set of processes or LWPs specified by a single idtype/id pair, priocntlset applies to a set of processes or LWPs that results from a logical combination of two idtype/id pairs. The input argument psp points to a procset structure that specifies the two idtype/id pairs and the logical operation to perform. This structure is defined in procset.h:

   typedef struct procset {
           idop_t    p_op;         /* operator connecting */
                                   /* left and right sets */
      /* left set:  */
           idtype_t  p_lidtype;    /* left ID type */
           id_t      p_lid;        /* left ID */

/* right set: */ idtype_t p_ridtype; /* right ID type */ id_t p_rid; /* right ID */ } procset_t;

p_lidtype and p_lid specify the ID type and ID of one (``left'') set of processes or LWPs; p_ridtype and p_rid specify the ID type and ID of a second (``right'') set of processes or LWPs. p_op specifies the operation to perform on the two sets of processes or LWPs to get the set of processes or LWPs to operate on. The valid values for p_op and the processes or LWPs they specify are:

The following macro, also defined in procset.h, offers a convenient way to initialize a procset structure :

   #define setprocset(psp, op, ltype, lid, rtype, rid) \
   		(psp)->p_op       = (op); \
   		(psp)->p_lidtype  = (ltype); \
   		(psp)->p_lid      = (lid); \
   		(psp)->p_ridtype  = (rtype); \
   		(psp)->p_rid      = (rid);

Here is a situation where priocntlset can be useful: an application has both real-time fixed priority and time-sharing processes that run under a single user ID. If the application wants to change the priority of only its fixed priority processes without changing the time-sharing processes to fixed priority processes, it can do so as follows. (This example uses the function schedinfo, which is defined above in the section on PC_GETCID.)

 *  Change fixed priorities of this uid
 *  to highest fixed priority minus 1.

main (argc, argv) int argc; char *argv[]; { procset_t procset; pcparms_t pcparms; struct fpparms *fpparmsp; id_t fpclassID; id_t schedinfo(); short maxfppri;

/* left set: select processes with same uid as this process */ procset.p_lidtype = P_UID; procset.p_lid = getuid();

/* get info on fixed priority class */ if ((fpclassID = schedinfo ("FP", &maxfppri)) == -1) { perror ("schedinfo failed"); exit (1); }

/* right set: select fixed priority processes */ procset.p_ridtype = P_CID; procset.p_rid = fpclassID;

/* select only my FP processes */ procset.p_op = POP_AND;

/* specify new scheduler parameters */ pcparms.pc_cid = fpclassID; fpparmsp = (struct fpparms *) pcparms.pc_clparms; fpparmsp->fp_pri = maxfppri - 1; fpparmsp->fp_tqnsecs = FP_NOCHANGE; if (priocntlset (&procset, PC_SETPARMS, &pcparms) == -1) { perror ("priocntlset failed"); exit (2); } }

priocntl offers a simple scheduler interface that is adequate for many applications; applications that need a more powerful way to specify sets of processes or LWPs can use priocntlset.

Next topic: Scheduler interaction with other functions
Previous topic: The priocntllist system call

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004