[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

thread_setsched Subroutine

Purpose

Changes the scheduling policy and priority of a kernel thread.

Library

Standard C library (libc.a)

Syntax

#include <sys/sched.h>
#include <sys/pri.h>
#include <sys/types.h>

int thread_setsched (tid, priority, policy)
tid_t tid;
int priority;
int policy;

Description

The thread_setsched subroutine changes the scheduling policy and priority of a kernel thread. User threads (pthreads) have their own scheduling attributes that in some cases allow a pthread to execute on top of multiple kernel threads. Therefore, if the policy or priority change is being granted on behalf of a pthread, then the pthread's contention scope should be PTHREAD_SCOPE_SYSTEM.

Note: Caution must be exercised when using the thread_setsched subroutine, since improper use may result in system hangs. See sys/pri.h for restrictions on thread priorities.

Parameters

tid Specifies the kernel thread ID of the thread whose priority and policy are to be changed.
priority Specifies the priority to use for this kernel thread. The priority parameter is ignored if the policy is being set to SCHED_OTHER. The priority parameter must have a value in the range 0 to PRI_LOW. PRI_LOW is defined in sys/pri.h. See sys/pri.h for more information on thread priorities.
policy Specifies the policy to use for this kernel thread. The policy parameter can be one of the following values, which are defined in sys/sched.h:
SCHED_OTHER Default AIX scheduling policy
SCHED_FIFO First in-first out scheduling policy
SCHED_RR Round-robin scheduling policy

Return Values

Upon successful completion, the thread_setsched subroutine returns a value of zero. If the thread_setsched subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The thread_setsched subroutine is unsuccessful if one or more of the following is true:

ESRCH The kernel thread id tid is invalid.
EINVAL The policy or priority is invalid.
EPERM The caller does not have enough privilege to change the policy or priority.

Implementation Specifics

This subroutine is part of the Base Operating System (BOS) Runtime.


[ Previous | Next | Contents | Glossary | Home | Search ]