pthread_get_nice_np.3t (2010 09)

p
pthread_get_nice_np(3T) pthread_get_nice_np(3T)
(Pthread Library)
NAME
pthread_get_nice_np(), pthread_set_nice_np() - get or set the nice value of a thread
SYNOPSIS
#include <pthread.h>
int pthread_get_nice_np(
pthread_t thread,
int *nice_val
);
int pthread_set_nice_np(
pthread_t thread,
int nice_val
);
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.
pthread_get_nice_np()
returns the current nice value setting of the target thread and stores it in
nice_val .
pthread_set_nice_np()
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
pthread_set_nice_np()
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
pthread_set_nice_np()
function allows individual threads in the process to have different nice
values.
pthread_get_nice_np()
returns the current nice value less 20 and will be in the range -20 to +19.
The nice value of only system scope (
PTHREAD_SCOPE_SYSTEM
) threads can be changed. An attempt to
change the nice value of a process-scope thread will result in a return value of [ENOTSUP]. Calling
pthread_set_nice_np()
on a thread that has a scheduling policy other than SCHED_HPUX will
have an effect only when the thread’s scheduling policy changes to
SCHED_HPUX. If a thread calls the
fork() system call to create a new process, the new process inherits the process-level nice value. Cal-
ling pthread_create()
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
nice() or setpriority(), 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 threads 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,
pthread_set_nice_np() and pthread_get_nice_np()
return
zero.
Otherwise, an error number is returned to indicate the error (the
errno variable is not set).
ERRORS
If any of the following occur, the
pthread_get_nice_np() and pthread_set_nice_np() func-
tions return the corresponding error:
[ENOTSUP] A process-scope thread was specified.
[EPERM] The caller does not have permission to lower the nice value specified in nice_val .
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)