Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

pthread_setscheduler(3-thr)                     pthread_setscheduler(3-thr)

NAME
     pthreadsetscheduler - changes the current scheduling policy and
     priority of a thread

SYNOPSIS
     #include <pthread.h>

     int pthreadsetscheduler(
          pthreadt 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:

                 SCHEDFIFO
                      (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.

                 SCHEDRR
                      (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.

                 SCHEDOTHER
                      (Default) All threads are timesliced. SCHEDOTHER
                      ensures that all threads, regardless of priority,
                      receive some scheduling, and thus no thread is com-
                      pletely denied execution time. (However, SCHEDOTHER
                      threads can be denied execution time by SCHEDFIFO or
                      SCHEDRR threads.)

                 SCHEDFGNP
                      (Foreground) Same as SCHEDOTHER. Threads are time-
                      sliced and priorities can be modified dynamically by
                      the scheduler to ensure fairness.

                 SCHEDBGNP
                      (Background) Like SCHEDOTHER, ensures that all
                      threads, regardless of priority, receive some
                      scheduling. However, SCHEDBGNP can be denied execu-
                      tion by any of the other scheduling policies.





Page 1                       Reliant UNIX 5.44                Printed 11/98

pthread_setscheduler(3-thr)                     pthread_setscheduler(3-thr)

     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:

                 PRIOTHERMIN <= priority <= PRIOTHERMAX

                 PRIFIFOMIN <= priority <= PRIFIFOMAX

                 PRIRRMIN <= priority <= PRIRRMAX

                 PRIFGMINNP <= priority <= PRIFGMAXNP

                 PRIBGMINNP <= priority <= PRIBGMAXNP

     If you create a new thread without specifying a threads attributes
     object that contains a changed priority attribute, the default prior-
     ity of the newly created thread is the midpoint between PRIOTHERMIN
     and PRIOTHERMAX (the midpoint between the minimum and the maximum
     for the SCHEDOTHER policy).

     When you call this routine to specify a minimum or maximum priority,
     use the appropriate symbol; for example, PRIFIFOMIN or PRIFIFOMAX.
     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 syn-
     tax:

          prirrmid = (PRIRRMIN + PRIRRMAX)/2

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

DESCRIPTION
     The pthreadsetscheduler() routine changes the current scheduling pol-
     icy 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 pthreadsetprio() routine.

     A thread changes its own scheduling policy and priority by using the
     identifier returned by pthreadself(). 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 pthreadattrsetprio() and
     pthreadattrsetsched() 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 rou-
     tine, however, changes the priority and scheduling policy of an exist-
     ing thread.




Page 2                       Reliant UNIX 5.44                Printed 11/98

pthread_setscheduler(3-thr)                     pthread_setscheduler(3-thr)

RETURN VALUES
     If successful, the previous scheduling policy value is returned. If
     the function fails, errno may be set to one of the following values:

     EINVAL    The value specified by thread is invalid.

     ENOTSUP   An attempt is made to set the policy to an unsupported
               value.

     ESRCH     The value specified by thread does not refer to an existing
               thread.

     EPERM     The caller does not have the appropriate privileges to set
               the scheduling policy of the specified thread.

SEE ALSO
     pthreadattrsetprio(3-thr), pthreadattrsetsched(3-thr),
     pthreadcreate(3-thr), pthreadself(3-thr), pthreadsetprio(3-thr).




































Page 3                       Reliant UNIX 5.44                Printed 11/98

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