HELPLIB.HLB  —  POSIX Threads, PTHREAD routines, pthread_attr_setschedparam
    Changes the values of the parameters associated with a scheduling
    policy of the specified thread attributes object.

1  –  C Binding

    #include <pthread.h>

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

2  –  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 of the specified
    thread attributes object.

                                   NOTE

       The Threads Library provides only the sched_priority
       scheduling parameter. See below for information about this
       scheduling parameter.

3  –  Description

    This routine sets the scheduling parameters associated with
    the scheduling policy attribute of the thread attributes object
    specified by the attr argument.
    Scheduling Priority
    Use the sched_priority field of a sched_param structure 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. Before calling pthread_create(), call pthread_
    attr_setinheritsched() and specify the value PTHREAD_EXPLICIT_
    SCHED for the inherit argument.

    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 you are accessing
    shared data. With a sufficient number of processors present, all
    ready threads, regardless of priority, execute simultaneously.
    Even on a uniprocessor, a lower priority thread could either
    execute before or be interleaved with a higher priority thread,
    for example due to page fault behavior. See <REFERENCE>(intro_
    threads_chap) and <REFERENCE>(threads_concepts_chap) for more
    information.

    Valid values of the sched_priority scheduling parameter depend on
    the chosen scheduling policy. Use the POSIX routines sched_get_
    priority_min() or sched_get_priority_max()  to determine the low
    and high limits of each policy.

    Additionally, the Threads Library provides nonportable priority
    range constants, as follows:

    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 varies by platform. On Tru64 UNIX, the
    default is 19 (that is, the POSIX priority of a normal timeshare
    process). On other platforms, the default priority is the
    midpoint between PRI_FG_MIN_NP and PRI_FG_MAX_NP.

4  –  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 attr is not a valid thread
                attributes object, or the value specified by param is
                invalid.
    [ENOTSUP]   An attempt was made to set the attribute to an
                unsupported value.

5  –  Associated Routines

       pthread_attr_init()
       pthread_attr_getschedparam()
       pthread_attr_setinheritsched()
       pthread_attr_setschedpolicy()
       pthread_create()
       sched_yield()
Close Help