System Interface Guide

Commands and Functions

Figure 3-2 illustrates the default process priorities.

Figure 3-2 Process Priorities (Programmer's View)


A process priority has meaning only in the context of a scheduler class. You specify a process priority by specifying a class and a class-specific priority value. The class and class-specific value are mapped by the system into a global priority that the system uses to schedule processes.

A system administrator's view of priorities is different from that of a user or programmer. When configuring scheduler classes, an administrator deals directly with global priorities. The system maps priorities supplied by users into these global priorities. See System Administration Guide, Volume I for more information about priorities.

The ps(1)command with -cel options reports global priorities for all active processes. The priocntl(1) command reports the class-specific priorities that users and programmers use.

The priocntl(1) command and the priocntl(2) and priocntlset(2) functions set or retrieve scheduler parameters for processes. Setting priorities is generally the same for all three functions:

These IDs are basic properties of UNIX processes. (See Intro(2).) The class ID is the scheduler class of the process. priocntl(2) works only for the time-sharing and the real-time classes, not for the system class.

Thepriocntl(1) Command

The priocntl(1) utility performs four different control functions on the scheduling of a process:

priocntl -l

displays configuration information  

priocntl -d

displays the scheduling parameters of processes 

priocntl -s

sets the scheduling parameters of processes 

priocntl -e

executes a command with the specified scheduling parameters  

The following are some examples of using priocntl(1).

The output of the -l option for the default configuration is:

$ priocntl -d -i all

SYS (System Class)

TS (Time Sharing)
Configured TS User Priority Range -20 through 20

RT (Real Time)
Maximum Configured RT Priority: 59

An example of displaying information on all processes:

$ priocntl -d -i all

An example of displaying information on all time-sharing processes:

$ priocntl -d -i class TS

An example of displaying information on all processes with user ID 103 or 6626:

$ priocntl -d -i uid 103 6626

An example of making the process with ID 24668 a real-time process with default parameters:

$ priocntl -s -c RT -i pid 24668

An example of making 3608 RT with priority 55 and a one-fifth second time slice:

$ priocntl -s -c RT -p 55 -t 1 -r 5 -i pid 3608

An example of changing all processes into time-sharing processes:

$ priocntl -s -c TS -i all

For uid 1122, reduce TS user priority and user priority limit to -10:

$ priocntl -s -c TS -p -10 -m -10 -i uid 1122

An example of starting a real-time shell with default real-time priority:

$ priocntl -e -c RT /bin/sh

An example of running make with a time-sharing user priority of -10:

$ priocntl -e -c TS -p -10 make bigprog

priocntl(1) subsumes the function of nice(1). nice works only on time-sharing processes and uses higher numbers to assign lower priorities. The example above is equivalent to using nice(1) to set an "increment" of 10:

$ nice -10 make bigprog

Thepriocntl(2) Function

priocntl(2) gets or sets the scheduling parameters of a process or set of processes much as the priocntl(1) utility does for a process. An invocation of priocntl(2) can act on a LWP, on a single process, or on a group of processes. A group of processes can be identified by parent process, process group, session, user, group, class, or all active processes. The manual page contains the details of its use.

An example of using priocntl(2) to do the equivalent of % priocntl -l is in Appendix A, Full Code Examples.

The PC_GETCLINFO command gets a scheduler class name and parameters given the class ID. This command makes it easy to write programs that make no assumptions about what classes are configured. An example of using priocntl(2) with PC_GETCLINFO to get the class name of a process based on the process ID is in Example A-2.

The PC_SETPARMS command sets the scheduler class and parameters of a set of processes. The idtype and id input arguments specify the processes to be changed. Example A-3 provides an example of using priocntl(2) with the PC_SETPARMS command to convert a time-share process into a real-time process.

The priocntlset(2) Function

The priocntlset(2) function changes scheduler parameters of a set of processes, like priocntl(2). priocntlset(2) has the same command set as priocntl(2). The cmd and arg input arguments are the same. But while priocntl(2) applies to a set of processes specified by a single idtype/id pair, priocntlset(2) applies to a set of processes that results from a logical combination of two idtype/id pairs. Again, refer to the manual page for details.

An example of using priocntlset(2) to change the priority of a real-time processes without changing time-sharing processes with the same user ID to real-time processes is in Example A-4.