[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_attr_setschedparam

Changes the values of the parameters associated with a scheduling policy of the specified thread attributes object.

Syntax

pthread_attr_setschedparam(
                           attr,
                           param );
 


Argument Data Type Access

attr opaque pthread_attr_t write param struct sched_param read


C Binding

#include 

int pthread_attr_setschedparam ( pthread_attr_t *attr, const struct sched_param *param);

Arguments

attr
Thread attributes object for the scheduling policy attribute whose parameters are to be set.
param
A structure containing new values for scheduling parameters associated with the scheduling policy attribute defined for the specified thread attributes object.

Note
DECthreads provides only the sched_priority scheduling parameter. It allows you to specify the scheduling priority. See below for information about this scheduling parameter.

Description

This routine sets the scheduling parameters associated with the scheduling policy attribute for the thread attributes object specified by the attr argument.

Scheduling Priority

Use the sched_priority scheduling parameter to set a thread's execution priority. The effect of the scheduling priority you assign depends on the scheduling policy specified for the attributes object specified by the attr argument.

By default, a created thread inherits the priority of the thread calling pthread_create. To specify a priority using this routine, scheduling inheritance must be disabled at the time the thread is created. Call pthread_attr_setinheritsched and specify the value PTHREAD_EXPLICIT_SCHED for the inherit argument before calling pthread_create.

An application specifies priority only to express the urgency of executing the thread relative to other threads. DO NOT USE PRIORITY TO CONTROL MUTUAL EXCLUSION WHEN ACCESSING SHARED DATA. With a sufficient number of processors executing, all ready threads, regardless of priority, execute simultaneously.

Valid values of the sched_priority scheduling parameter depend on the chosen policy and fall within one of the following ranges:


Policy            Low               High

SCHED_FIFO PRI_FIFO_MIN PRI_FIFO_MAX SCHED_RR PRI_RR_MIN PRI_RR_MAX SCHED_OTHER PRI_OTHER_MIN PRI_OTHER_MAX SCHED_FG_NP PRI_FG_MIN_NP PRI_FG_MAX_NP SCHED_BG_NP PRI_BG_MIN_NP PRI_BG_MAX_NP


The default priority is the midpoint between PRI_OTHER_ MIN and PRI_OTHER_MAX for the SCHED_OTHER policy. (Section 2.7 describes how to specify priorities between the minimum and maximum values.)

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Return        Description

0 Successful completion. [EINVAL] The value specified by param is invalid. [ENOTSUP] An attempt was made to set the attribute to an unsupported value.


Associated Routines

   pthread_attr_init
   pthread_attr_getschedparam
   pthread_attr_setinheritsched
   pthread_attr_setschedpolicy
   pthread_create
   sched_yield



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]