VMS Help
DCE_THREADS, Application Routines, pthread_setscheduler

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

  NAME

      pthread_setscheduler - Changes the current scheduling policy
                             and priority of a thread

  SYNOPSIS

      #include <pthread.h>

      int pthread_setscheduler( pthread_t thread,
                                int       scheduler,
                                int       priority );

  PARAMETERS

      thread                Thread whose scheduling policy is to be
                            changed.

      scheduler             New scheduling policy value for the thread
                            specified in thread.  Valid values are as
                            follows:

                            SCHED_FIFO (First In, First Out)
                                      The highest-priority thread runs
                                      until it blocks. If there is more
                                      than one thread with the same
                                      priority, and that priority is the
                                      highest among other threads, the
                                      first thread to begin running
                                      continues until it blocks.

                            SCHED_RR (Round Robin)
                                      The highest-priority thread runs
                                      until it blocks; however, threads
                                      of equal priority, if that priority
                                      is the highest among other threads,
                                      are timesliced.  Timeslicing is a
                                      process in which threads alternate
                                      using available processors.

                            SCHED_OTHER (Default)
                                      All threads are timesliced.
                                      SCHED_OTHER ensures that all
                                      threads, regardless of priority,
                                      receive some scheduling, and thus
                                      no thread is completely denied
                                      execution time. (However, SCHED_OTHER
                                      threads can be denied execution time
                                      by SCHED_FIFO or SCHED_RR threads.)

                            SCHED_FG_NP (Foreground)
                                      Same as SCHED_OTHER.  Threads are
                                      timesliced and priorities can be
                                      modified dynamically by the scheduler
                                      to ensure fairness.

                            SCHED_BG_NP (Background)
                                      Like SCHED_OTHER, ensures that all
                                      threads, regardless of priority,
                                      receive some scheduling.  However,
                                      SCHED_BG_NP can be denied execution
                                      by any of the other scheduling
                                      policies.

      priority              New priority value of the thread specified in
                            thread. The priority attribute depends on
                            scheduling policy. Valid values fall within
                            one of the following ranges:

                            o    PRI_OTHER_MIN <= priority <= PRI_OTHER_MAX

                            o    PRI_FIFO_MIN <= priority <= PRI_FIFO_MAX

                            o    PRI_RR_MIN <= priority <= PRI_RR_MAX

                            o    PRI_FG_MIN_NP <= priority <= PRI_FG_MAX_NP

                            o    PRI_BG_MIN_NP <= priority <= PRI_BG_MAX_NP

  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 midway 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

  The pthread_setscheduler() routine changes the current scheduling policy
  and priority of a thread.  Call this routine to change both the priority
  and scheduling policy of a thread at the same time. To change  only  the
  priority, call the pthread_setprio() routine.

  A thread changes its own scheduling policy and  priority  by  using  the
  identifier  returned  by pthread_self().  Changing the scheduling policy
  or priority, or both, of a thread can cause it to start executing or  to
  be preempted by another thread.

  This     routine     differs     from     pthread_attr_setprio()     and
  pthread_attr_setsched()  because  those  routines  set  the priority and
  scheduling policy attributes that are used to establish the priority and
  scheduling policy of a new thread when it is created. This routine, how-
  ever, changes the priority and scheduling policy of an existing thread.

  RETURN VALUES

  If the function fails, errno may be set to one of the following values:

    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

      FUNCTIONS:  pthread_attr_setprio
                  pthread_attr_setsched
                  pthread_create
                  pthread_self
                  pthread_setprio
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.