pthread_getschedparam, pthread_setschedparam - dynamic thread scheduling parameters access (REALTIME THREADS)
#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);
The 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 implementation-dependent.The pthread_getschedparam() function 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() shall be the value specified by the most recent pthread_setschedparam() or pthread_create() call affecting the target thread. It shall not reflect any temporary adjustments to its priority as a result of any priority inheritance or ceiling functions. The pthread_setschedparam() function 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, that has implementation-dependent scheduling parameters, SCHED_FIFO or SCHED_RR, that have the single scheduling parameter, priority.
If the pthread_setschedparam() function fails, no scheduling parameters will be changed for the target thread.
If successful, the pthread_getschedparam() and pthread_setschedparam() functions return zero. Otherwise, an error number is returned to indicate the error.
The pthread_getschedparam() and pthread_setschedparam() functions will fail if:
- [ENOSYS]
- The option _POSIX_THREAD_PRIORITY_SCHEDULING is not defined and the implementation does not support the function.
The pthread_getschedparam() function may fail if:
- [ESRCH]
- The value specified by thread does not refer to a existing thread.
The pthread_setschedparam() function may fail if:
- [EINVAL]
- The value specified by policy or one of the scheduling parameters associated with the scheduling policy policy is invalid.
- [ENOTSUP]
- An attempt was made to set the policy or scheduling parameters to an unsupported value.
- [EPERM]
- The caller does not have the appropriate permission to set either the scheduling parameters or the scheduling policy of the specified thread.
- [EPERM]
- The implementation does not allow the application to modify one of the parameters to the value specified.
- [ESRCH]
- The value specified by thread does not refer to a existing thread.
None.
None.
None.
sched_setparam(), sched_getparam(), sched_setscheduler(), sched_getscheduler(), <pthread.h>, <sched.h>.
Derived from the POSIX Threads Extension (1003.1c-1995)