[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

pthread_setschedparam Subroutine

Purpose

Returns the current schedpolicy and schedparam attributes of a thread.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>
#include <sys/sched.h>

int pthread_setschedparam (thread, schedpolicy, schedparam)
pthread_t thread;
int schedpolicy;
const struct sched_param *schedparam;

Description

The pthread_setschedparam subroutine dynamically sets the schedpolicy and schedparam attributes of the thread thread. The schedpolicy attribute specifies the scheduling policy of the thread. The schedparam attribute specifies the scheduling parameters of a thread created with this attributes object. The sched_priority field of the sched_param structure contains the priority of the thread. It is an integer value.

If the target thread has system contention scope, the process must have root authority to set the scheduling policy to either SCHED_FIFO or SCHED_RR.

Note
The pthread.h header file must be the first included file of each source file using the threads library. Otherwise, the -D_THREAD_SAFE compilation flag should be used, or the cc_r compiler used. In this case, the flag is automatically set.

This subroutine is part of the Base Operating System (BOS) Runtime. The implementation of this subroutine is dependent on the priority scheduling POSIX option. The priority scheduling POSIX option is implemented in the operating system.

Parameters

thread Specifies the target thread.
schedpolicy Points to the schedpolicy attribute to set. It must have one of the following values:
SCHED_FIFO
Denotes first-in first-out scheduling.
SCHED_RR
Denotes round-robin scheduling.
SCHED_OTHER
Denotes the default operating system scheduling policy. It is the default value.
Note
It is not permitted to change the priority of a thread when setting its scheduling policy to SCHED_OTHER. In this case, the priority is managed directly by the kernel, and the only legal value that can be passed to pthread_setschedparam is DEFAULT_PRIO, which is defined in pthread.h as 1.
schedparam Points to where the scheduling parameters to set are stored. The sched_priority field must be in the range from 1 to 127, where 1 is the least favored priority, and 127 the most favored.

Return Values

Upon successful completion, 0 is returned. Otherwise, an error code is returned.

Error Codes

The pthread_setschedparam subroutine is unsuccessful if the following is true:

EINVAL The thread or schedparam parameters are not valid.
ENOSYS The priority scheduling POSIX option is not implemented.
ENOTSUP The value of the schedpolicy or schedparam attributes are not supported.
EPERM The target thread has insufficient permission to perform the operation or is already engaged in a mutex protocol.
ESRCH The thread thread does not exist.

Related Information

The pthread_getschedparam (pthread_getschedparam Subroutine) subroutine, pthread_attr_setschedparam (pthread_attr_setschedparam Subroutine) subroutine.

Threads Scheduling in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

Threads Library Options in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

Threads Library Quick Reference in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]