pthread_getschedparam(3pthread)


pthread_getschedparam, pthread_setschedparam -- dynamic thread scheduling parameters access

Synopsis

cc [options] -Kthread file

#include <pthread.h>

int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param); int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param);

Description

pthread_getschedparam and pthread_setschedparam allow the scheduling policy and scheduling parameters of individual threads within a multi-threaded process to be retrieved and set. For SCHED_FIFO and SCHED_RR, the only required member of the sched_param structure is the priority sched_priority. For SCHED_OTHER, the affected scheduling parameters are the same.

pthread_getschedparam retrieves the scheduling policy and scheduling parameters for the thread whose thread ID is given by thread and stores those values in policy and param, respectively. The priority value returned from pthread_getschedparam is the value specified by the most recent pthread_setschedparam or pthread_create(3pthread) call affecting the target thread, and reflects any temporary adjustments to its priority as a result of any priority inheritance or ceiling functions. pthread_setschedparam sets the scheduling policy and associated scheduling parameters for the thread whose thread ID is given by thread to the policy and associated parameters provided in policy and param, respectively.

The policy parameter may have the value SCHED_OTHER, SCHED_FIFO or SCHED_RR, that have the single scheduling parameter, sched_priority.

If pthread_setschedparam fails, no scheduling parameters will be changed for the target thread.

Return values

If successful, pthread_getschedparam and pthread_setschedparam return zero. Otherwise, an error number is returned to indicate the error.

Diagnostics

If the following condition is detected, pthread_getschedparam and pthread_setschedparam will return the corresponding value:

ESRCH
value specified by thread does not refer to an existing thread.

If the following conditions are detected, pthread_setschedparam will return the corresponding values:


EINVAL
policy or one of the scheduling parameters associated with the scheduling policy policy is invalid.

ENOTSUP
attempt was made to set the policy or scheduling parameters to an unsupported value.

EPERM
caller does not have the appropriate permission to set either the scheduling parameters or the scheduling policy of the specified thread.

References

pthread_attr_getschedparam(3pthread) pthread_attr_setschedparam(3pthread) pthread(4), sched(4)

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004