The listing below shows which classes are configured on your system, and the user priority range for the timesharing class. The possible classes are:
System (SYS)
Interactive (IA)
Real-time (RT)
The priority of a process is inherited from the parent process. This is referred to as the user-mode priority.
The system looks up the user-mode priority in the timesharing dispatch parameter table and adds in any nice or priocntl (user-supplied) priority and ensures a 0-59 range to create a global priority.
The scheduling priority of a process is the priority it is assigned by the process scheduler, according to scheduling policies. The dispadmin command lists the default scheduling policies.
The priocntl(1) command can be used to assign processes to a priority class and to manage process priorities. See the section called "How to Designate a Process Priority" for instructions on using the priocntl command to manage processes.
You can display process class and scheduling parameters with the priocntl -l command.
$ priocntl -l |
The following example shows output from the priocntl -l command.
# priocntl -l CONFIGURED CLASSES ================== SYS (System Class) TS (Time Sharing) Configured TS User Priority Range: -60 through 60 IA (Interactive) Configured IA User Priority Range: -60 through 60 RT (Real Time) Maximum Configured RT Priority: 59 |
You can display the global priority of a process by using the ps command.
$ ps -ecl |
The global priority is listed under the PRI column.
The following example shows output from ps -ecl. Data in the PRI column show that pageout has the highest priority, while sh has the lowest.
$ ps -ecl F S UID PID PPID CLS PRI ADDR SZ WCHAN TTY TIME COMD 19 T 0 0 0 SYS 96 f00d05a8 0 ? 0:03 sched 8 S 0 1 0 TS 50 ff0f4678 185 ff0f4848 ? 36:51 init 19 S 0 2 0 SYS 98 ff0f4018 0 f00c645c ? 0:01 pageout 19 S 0 3 0 SYS 60 ff0f5998 0 f00d0c68 ? 241:01 fsflush 8 S 0 269 1 TS 58 ff0f5338 303 ff49837e ? 0:07 sac 8 S 0 204 1 TS 43 ff2f6008 50 ff2f606e console 0:02 sh |
Start a process with a designated priority.
# priocntl -e -c class -m userlimit -p pri command_name |
-e |
Executes the command. |
-c class |
Specifies the class within which to run the process. The default classes are TS (timesharing) or RT (real-time). |
-m userlimit |
Specifies the maximum amount you can raise or lower your priority, when using the -p option. |
-p pri command_name |
Lets you specify the relative priority in the RT class, for a real-time thread. For a timesharing process, the -p option lets you specify the user-supplied priority which ranges from -20 to +20. |
Verify the process status by using the ps -ecl command.
# ps -ecl | grep command_name |
The following example starts the find command with the highest possible user-supplied priority.
# priocntl -e -c TS -m 20 -p 20 find . -name core -print # ps -ecl | grep find |
Change the scheduling parameter of a running timeshare process.
# priocntl -s -m userlimit [-p userpriority] -i idtype idlist |
-s |
Lets you set the upper limit on the user priority range and change the current priority. |
-m userlimit |
Specifies the maximum amount you can raise or lower your priority, when using the -p option. |
-p userpriority |
Allows you to designate a priority. |
-iidtype idlist |
Uses a combination of idtype and idlist to identify the process. The idtype specifies the type of ID, such as PID or UID. |
Verify the process status by using the ps -ecl command.
# ps -ecl | grep idlist |
The following example executes a command with a 500-millisecond time slice, a priority of 20 in the RT class, and a global priority of 120.
# priocntl -e -c RT -t 500 -p 20 myprog # ps -ecl | grep myprog |
You must be superuser or working in a real-time shell to change processes from, or to, real-time processes.
Change the class of a process.
# priocntl -s -c class -i idtype idlist |
-s |
Lets you set the upper limit on the user priority range and change the current priority. |
-c class |
Specifies the class, TS or RT, to which you are changing the process. |
-i idtype idlist |
Uses a combination of idtype and idlist to identify the process. The idtype specifies the type of ID, such as PID or UID. |
Verify the process status by using the ps -ecl command.
# ps -ecl | grep idlist |
The following example changes all the processes belonging to user 15249 to real-time processes.
# priocntl -s -c RT -i uid 15249 # ps -ecl | grep 15249 |
If, as superuser, you change a user process to the real-time class, the user cannot subsequently change the real-time scheduling parameters (using priocntl -s).
The nice(1) command is only supported for backward compatibility to previous Solaris releases. The priocntl command provides more flexibility in managing processes.
The priority of a process is determined by the policies of its scheduling class, and by its nice number. Each timesharing process has a global priority which is calculated by adding the user-supplied priority, which can be influenced by the nice or priocntl commands, and the system-calculated priority.
The execution priority number of a process is assigned by the operating system, and is determined by several factors, including its schedule class, how much CPU time it has used, and (in the case of a timesharing process) its nice number.
Each timesharing process starts with a default nice number, which it inherits from its parent process. The nice number is shown in the NI column of the ps report.
A user can lower the priority of a process by increasing its user-supplied priority. But only the superuser can lower a nice number to increase the priority of a process. This is to prevent users from increasing the priorities of their own processes, thereby monopolizing a greater share of the CPU.
Nice numbers range between 0 and +40, with 0 representing the highest priority. The default value is 20. Two versions of the command are available, the standard version, /usr/bin/nice, and a version that is part of the C shell.
You can raise or lower the priority of a command or a process by changing the nice number. To lower the priority of a process:
/usr/bin/nice command_name |
Increase the nice number by four units (the default) |
/usr/bin/nice +4 command_name |
Increase the nice number by four units |
/usr/bin/nice -10 command_name |
Increase the nice number by ten units |
The first and second commands increase the nice number by four units (the default); and the third command increases the nice by ten units, lowering the priority of the process.
The following commands raise the priority of the command by lowering the nice number.
To raise the priority of a process:
/usr/bin/nice -10 command_name |
Raises the priority of the command by lowering the nice number |
/usr/bin/nice - -10 command_name |
Raises the priority of the command by lowering the nice number. The first minus sign is the option sign, and the second minus sign indicates a negative number. |
The above commands raise the priority of the command, command_name, by lowering the nice number. Note that in the second case, the two minus signs are required.
Here are some tips on obvious problems you may find:
Look for several identical jobs owned by the same user. This may come as a result of running a script that starts a lot of background jobs without waiting for any of the jobs to finish.
Look for a process that has accumulated a large amount of CPU time. You'll see this by looking at the TIME field. Possibly, the process is in an endless loop.
Look for a process running with a priority that is too high. Type ps -c to see the CLS field, which displays the scheduler class of each process. A process executing as a real-time (RT) process can monopolize the CPU. Or look for a timeshare (TS) process with a high nice value. A user with superuser privileges may have bumped up the priorities of this process. The system administrator can lower the priority by using the nice command.
Look for a runaway process--one that progressively uses more and more CPU time. You can see it happening by looking at the time when the process started (STIME) and by watching the cumulation of CPU time (TIME) for awhile.