Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pthread_attr_setprio(3)

pthread_attr_setsched(3)

pthread_create(3)

pthread_self(3)

pthread_setscheduler(3)

pthread_setprio(3)  —  Subroutines

Digital

NAME

pthread_setprio − Changes the current priority of a thread. 

SYNOPSIS

#include <pthread.h>
int pthread_setprio(

pthread_t thread ,
int priority );

PARAMETERS

threadThread whose priority is changed. 

priorityNew priority value of the thread specified in thread. The priority value is dependent upon scheduling policy. Valid values fall within one of the following three ranges. 

PRI_OTHER_MIN <= priority <= PRI_OTHER_MAX

PRI_FIFO_MIN <= priority <= PRI_FIFO_MAX

PRI_RR_MIN <= priority <= PRI_RR_MAX

If you create a new thread without specifying a threads attributes object that contains a changed priority attribute, the default priority of the newly created thread is the midpoint between PRI_OTHER_MIN and PRI_OTHER_MAX (the midpoint between the minimum and the maximum for the SCHED_OTHER policy). 

When you call this routine to specify a minimum or maximum priority, use the appropriate symbol — for example, PRI_FIFO_MIN or PRI_FIFO_MAX. To specify a value between the minimum and maximum, use an appropriate arithmetic expression. For example, to specify a priority mid-way between the minimum and maximum for the Round Robin scheduling policy, specify the following concept using your programming language’s syntax:

pri_rr_mid = (PRI_RR_MIN + PRI_RR_MAX)/2

If your expression results in a value outside the range of minimum to maximum, an error results when you use it. 

DESCRIPTION

This routine changes the current priority of a thread. A thread can change its own priority using the identifier returned by pthread_self. 

Changing the priority of a thread can cause it to start executing or be preempted by another thread. The effect of setting different priority values depends on the scheduling priority assigned to the thread. The initial scheduling priority is set by calling the pthread_attr_setprio routine. 

Note that pthread_attr_setprio sets the priority attribute that is used to establish the priority of a new thread when it is created.  However, pthread_setprio changes the priority of an existing thread. 

RETURN VALUES

If an error condition occurs, this routine returns −1 and sets errno to the corresponding error value. Possible return values are as follows:

Return Error Description
 0 Successful completion.
−1 [EINVAL] The value specified by thread is invalid.
−1 [ENOTSUP] An attempt is made to set the policy to an unsupported value. 
−1 [ESRCH] The value specified by thread does not refer to an existing thread. 
−1 [EPERM] The caller does not have the appropriate privileges to set the priority of the specified thread. 

RELATED INFORMATION

pthread_attr_setprio(3), pthread_attr_setsched(3), pthread_create(3), pthread_self(3), pthread_setscheduler(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026