Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

nice(2) [opensolaris man page]

nice(2) 							   System Calls 							   nice(2)

NAME
nice - change priority of a process SYNOPSIS
#include <unistd.h> int nice(int incr); DESCRIPTION
The nice() function allows a process to change its priority. The invoking process must be in a scheduling class that supports the nice(). The nice() function adds the value of incr to the nice value of the calling process. A process's nice value is a non-negative number for which a greater positive value results in lower CPU priority. A maximum nice value of (2 * NZERO) -1 and a minimum nice value of 0 are imposed by the system. NZERO is defined in <limits.h> with a default value of 20. Requests for values above or below these limits result in the nice value being set to the corresponding limit. A nice value of 40 is treated as 39. Calling the nice() function has no effect on the priority of processes or threads with policy SCHED_FIFO or SCHED_RR. Only a process with the {PRIV_PROC_PRIOCNTL} privilege can lower the nice value. RETURN VALUES
Upon successful completion, nice() returns the new nice value minus NZERO. Otherwise, -1 is returned, the process's nice value is not changed, and errno is set to indicate the error. ERRORS
The nice() function will fail if: EINVAL The nice() function is called by a process in a scheduling class other than time-sharing or fixed-priority. EPERM The incr argument is negative or greater than 40 and the {PRIV_PROC_PRIOCNTL} privilege is not asserted in the effective set of the calling process. USAGE
The priocntl(2) function is a more general interface to scheduler functions. Since -1 is a permissible return value in a successful situation, an application wishing to check for error situations should set errno to 0, then call nice(), and if it returns -1, check to see if errno is non-zero. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
nice(1), exec(2), priocntl(2), getpriority(3C), attributes(5), privileges(5), standards(5) SunOS 5.11 1 Apr 2004 nice(2)

Check Out this Related Man Page

pthread_get_nice_np(3T) 												   pthread_get_nice_np(3T)

NAME
pthread_get_nice_np(), pthread_set_nice_np() - get or set the nice value of a thread SYNOPSIS
PARAMETERS
thread The thread whose nice value is to be set/retrieved. nice_val Value of nice to be applied to the target thread is returned (get function) or it specifies the new value of nice for thread (set function). DESCRIPTION
These functions are used to set and retrieve the nice value of an individual thread. returns the current nice value setting of the target thread and stores it in nice_val. adds the value of nice_val to the current nice value of the target thread. A thread's nice value is a non-negative number. The system imposes a minimum nice value of 0 and a maximum of 39 with lower nice values providing more favorable scheduling. If calling results in a nice value outside the range of 0 to 39, the value will be set to the nearest limit. A process must have appropriate privileges to lower a thread's nice value. The function allows individual threads in the process to have different nice values. returns the current nice value less 20 and will be in the range -20 to +19. The nice value of only system scope threads can be changed. An attempt to change the nice value of a process-scope thread will result in a return value of Calling on a thread that has a scheduling policy other than will have an effect only when the thread's scheduling policy changes to If a thread calls the system call to create a new process, the new process inherits the process-level nice value. Calling to create a new thread will result in the new thread inheriting the creating thread's nice value. Note If the nice value of the entire process is changed through or all the threads in the process will have their nice values reset to the new process-level nice value. The new process's nice value setting overwrites the old thread's setting. Thus its possible that a thread whose nice value had been set higher than the process-level nice value have its nice value lowered as a result of the process-level re-nicing. RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the and functions return the corresponding error: A process-scope thread was specified. The caller does not have permission to lower the nice value specified in nice_val. No thread could be found corresponding to thread. AUTHOR
and were developed by HP. SEE ALSO
fork(2), nice(2), setpriority(2), pthread_attr_getschedpolicy(3T), pthread_setschedparam(3T). Pthread Library pthread_get_nice_np(3T)
Man Page