Go to main content

Oracle® Solaris 11.4 Programming Interfaces Guide

Exit Print View

Updated: November 2020

Process Priority Commands and Interfaces

The following figure illustrates the default process priorities.

Figure 1  Process Priorities (Programmer's View)

image:Image shows priority of real-time over system threads, and system threads over time-sharing threads. Each class has a separate run queue.

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 the view 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. For more information about priorities, see Displaying and Managing Process Class Information in Managing System Information, Processes, and Performance in Oracle Solaris 11.4.

The ps command with –cel options reports global priorities for all active processes. The priocntl command reports the class-specific priorities that users and programmers use. For more information, see the ps(1) and priocntl(1) man pages.

The priocntl(1) command and the priocntl(2) and priocntlset(2) interfaces are used to set or retrieve scheduler parameters for processes. Setting priorities generally follows the same sequence for the command and both interfaces:

  1. Specify the target processes.

  2. Specify the scheduler parameters that you want for those processes.

  3. Execute the command or interface to set the parameters for the processes.

Process IDs are basic properties of UNIX processes. For more information, see the Intro(2) man page. 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. For more information, see the priocntl(1), priocntl(2), and priocntlset(2) man pages.

priocntl Command

The priocntl utility performs four different control interfaces 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 examples demonstrate the use of the priocntl command:

  • The –l option for the default configuration produces the following output:

    $ priocntl -l
    SYS (System Class)
    TS (Time Sharing)
    Configured TS User Priority Range -60 through 60
    RT (Real Time)
    Maximum Configured RT Priority: 59
  • Display information about all processes, by using the following:

    $ priocntl -d -i all
  • Display information about all time-sharing processes, by using the following:

    $ priocntl -d -i class TS
  • Display information about all processes with user ID 103 or 6626, by using the following:

    $ priocntl -d -i uid 103 6626
  • Make the process with ID 24668 a real-time process with default parameters, by using the following:

    $ priocntl -s -c RT -i pid 24668
  • Make 3608 RT with priority 55 and a one-fifth second time slice, by using the following:

    $ priocntl -s -c RT -p 55 -t 1 -r 5 -i pid 3608
  • Change all processes into time-sharing processes, by using the following:

    $ priocntl -s -c TS -i all
  • Reduce TS user priority and user priority limit to -10 for uid 1122, by using the following:

    $ priocntl -s -c TS -p -10 -m -10 -i uid 1122
  • Start a real-time shell with default real-time priority, by using the following:

    $ priocntl -e -c RT /bin/sh
  • Run make with a time-sharing user priority of -10, by using the following:

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

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

$ nice -10 make bigprog

For more information, see the priocntl(1) and nice(1) man pages.

priocntl() Function

Thepriocntl() function manages the scheduling parameters of a process or set of processes. An invocation of the priocntl() system callcan 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 PC_GETCLINFO command gets a scheduler class name and parameters when the class ID is given. This command enables you to write programs that make no assumptions about what classes are configured.

The PC_SETXPARMS command sets the scheduler class and parameters for a set of processes. The idtype and id input arguments specify the processes to be changed.

For more information, see the priocntl(2) man page.