Changes the values of the parameters associated with a scheduling policy of the specified thread attributes object.
pthread_attr_setschedparam( attr, param );
Argument Data Type Accessattr opaque pthread_attr_t write param struct sched_param read
#includeint pthread_attr_setschedparam ( pthread_attr_t *attr, const struct sched_param *param);
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 HighSCHED_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 Description0 Successful completion. [EINVAL] The value specified by param is invalid. [ENOTSUP] An attempt was made to set the attribute to an unsupported value.
pthread_attr_init pthread_attr_getschedparam pthread_attr_setinheritsched pthread_attr_setschedpolicy pthread_create sched_yield