Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sched_setscheduler(2) — DG/UX R4.11MU05

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

nice(1)

nice(2)

ps(1)



sched_setscheduler(2)          DG/UX R4.11MU05         sched_setscheduler(2)


NAME
       sched_setscheduler - set the scheduling policy and priority for a
       process

SYNOPSIS
       #include <sched.h>

       int schedsetscheduler (pid, policy, *priority)
            pidt               pid;
            int                 policy;
            struct schedparam  *priority;

DESCRIPTION
       Use schedsetscheduler(2) to set a process's scheduling policy and
       priority:

       pid       is the process id.

       policy    may be one of the following:

                 SCHED_DG_TS   The default DG/UX timesharing policy (same as
                               SCHED_OTHER described in POSIX
                               specifications)

                 SCHED_FIFO    First-in-first-out restricted fixed priority

                 SCHED_RR      Round robin restricted fixed priority with a
                               timeslice

                 SCHED_DG_FIFO FIFO unrestricted fixed priority

                 SCHED_DG_LIFO LIFO unrestricted fixed priority

                 See "Scheduling Policies" below for descriptions.

       priority  points to a structure containing the scheduling priority.

       The POSIX-specified structure that priority points to is:

       struct schedparam
           {
           int schedpriority;
           };

       If pid is 0, this call sets the scheduling policy and priority of the
       calling process.

       Only the calling process with appropriate privilege can change the
       scheduling policy, or set a priority that is higher than the current
       priority. A priority that is lower than or equal to the current
       priority may be set either by the calling process with appropriate
       privilege or by a process having an effective user id matching that
       of pid.  For systems supporting the DG/UX Capability Option,
       appropriate privilege is defined as having one or more specific
       capabilities enabled in the effective capability set of the calling
       process.  See capdefaults(5) for the default capability for this
       system call.

       On systems without the DG/UX Capability Option, appropriate privilege
       means that the process has an effective UID of root.  See the
       appropriateprivilege(5) man page for more information.

       The larger the number in schedpriority, the higher the priority.
       The number must be within the range for policy returned by
       schedgetprioritymin(2) and schedgetprioritymax(2).

       If this call fails, the policy and priority of pid are not changed.

       The scheduling policy and priority are inherited on a fork(2).

   Scheduling Priorities
       The system schedules a process based on its effective priority.  You
       can get the effective priority of a process with ps -c(1) or
       dgprocessinfo(2).  You can get the priority of a process that was
       set by this system call or by schedsetparam(2) with
       schedgetparam(2).

       The effective priority used by the system is equal to the priority
       set by this system call for the fixed priority scheduling classes.
       For a timesharing process (SCHED_DG_TS), the system determines its
       effective priority dynamically as explained below.

   Scheduling Policies
       The SCHED_DG_TS policy provides fair scheduling for timesharing
       processes.  The minimum and maximum priorities available to the
       SCHED_DG_TS class assure that a process created in this class will
       have a lower priority than any realtime (SCHED_FIFO or SCHED_RR)
       process or DG/UX kernel system process. Unless specifically changed
       by this call, the shell (sh or csh) belongs to the SCHED_DG_TS class.

       The system dynamically calculates the effective priorities of
       timesharing processes to enforce fairness. For example, the system
       may decrease the effective priority of a SCHED_DG_TS process that is
       consuming too much of the JP resources, or increase the effective
       priority of a SCHED_DG_TS process that is not making sufficient
       progress. The calculation is influenced by three factors:

        * The priority, which may be set by this system call or by
          schedsetparam(2)

        * The nice level, which may be set by nice(1) or nice(2)

        * The processor utilization level

       Determined by the system, the processor utilization level of a
       process is the sum of its starving level and interactive level.  A
       higher processor utilization level will result in a higher effective
       priority.

       The interactive level is a measurement of how soon the process will
       voluntarily give up the processor.  Thus, a process that continually
       blocks waiting for terminal I/O is more interactive than a compute-
       bound process.  The system assigns a higher interactive level to a
       highly interactive process. The higher interactive level results in a
       higher priority that improves the response time of the process. This
       works well for interactive processes because they typically are ready
       to give up a JP after running for only a short period of time.
       Conversely, the system assigns a lower interactive level to a less
       interactive process. This works well for less interactive processes
       because they tend to occupy the JP for a longer period of time,
       usually until removed by preemption.

       The system tries to guarantee that all timesharing processes make
       progress.  If a timesharing process is elgible to run but cannot make
       progress due to being starved by higher priority processes, the
       system will temporarily increase the starving level of the process.
       Increasing the starving level will give the process a priority boost
       that will allow it to make progress.  When the starved process makes
       progress, the system will reset its starving level back to zero.

       POSIX specifies a vendor-defined policy named SCHED_OTHER. In the
       DG/UX implementation, SCHED_OTHER is identical to SCHED_DG_TS.


       The POSIX-specified SCHED_FIFO class provides fixed priority
       scheduling for realtime processes.  The minimum and maximum
       priorities available to this class assure that a process in the class
       will have a higher priority than any timesharing (SCHED_DG_TS)
       process, but will have a lower priority than any DG/UX kernel system
       process.

       A SCHED_FIFO process:

        * Has an infinitely long time slice. Once it starts executing on a
          JP, it stays on the JP until it completes, is preempted by a
          higher-priority process, is blocked by an action that it takes, or
          voluntarily gives up the JP.

        * When it completes, is blocked, or voluntarily gives up the JP, the
          JP goes to the eligible process with the highest priority.

        * If preempted, is added to the eligible list ahead of processes of
          equal or lower priority.

        * If blocked, is added to the eligible list behind processes of
          greater or equal priority.

        * If it voluntarily gives up the JP with a schedyield(2) call, is
          placed in the eligible list behind processes of greater or equal
          priority.

        * If it changes its priority, is placed in the eligible list behind
          processes of greater or equal priority.  This is true even if the
          process changes its priority to its current priority.

        * Never has its priority changed by the system. Its priority is not
          affected by its nice(2) value.  However, if the nice(2) value is
          changed, the new value will apply should the process change into
          the timesharing (SCHED_DG_TS) scheduling class.


       The POSIX-specified SCHED_RR (round robin) policy is identical to the
       SCHED_FIFO policy except that a SCHED_RR process:

        * Has a specific time slice, returned by schedrrgetinterval(2).
          When a SCHED_RR process has been executing for this interval (or
          longer), it gives up the JP and is added to the eligible list
          behind processes of higher or equal priority.

        * Upon completing its execution interval, or if blocked, is given a
          new full execution interval the next time it executes.

        * If preempted, is given the remainder of its previous execution
          interval the next time it executes.

       The SCHED_RR time slice is the value of the system variable MAXSLICE.
       This value, 100 ms by default, may be changed during system
       configuration.


       The SCHED_DG_FIFO class provides fixed-priority FIFO scheduling for
       users whose needs are not met by the SCHED_FIFO policy.  The
       priorities available to the SCHED_DG_FIFO class include the entire
       range of priorities available on the system.  This range includes
       priorities higher than DG/UX kernel system processes and lower than
       timesharing (SCHED_DG_TS) processes. Except for this unrestricted
       priority range, the SCHED_DG_FIFO policy is identical to the
       SCHED_FIFO policy.

       The SCHED_DG_LIFO class is identical to SCHED_DG_FIFO except that
       when the process is added to the elgible list, it is added ahead of
       processes of equal or lower priority.  This class is more concerned
       with completing a process once it has started than being fair to
       other processes of equal priority.

       The SCHED_FIFO policy is sufficient for most realtime applications
       and, where so, is preferable to SCHED_DG_FIFO or SCHED_DG_LIFO.  Use
       SCHED_DG_FIFO rather than SCHED_FIFO or SCHED_DG_LIFO for a realtime
       process that:

        * Requires the best priority in the system regardless of any
          potential consequences resulting from interference with the DG/UX
          kernel system processes.

        * Needs a priority low enough to force it to compete with
          timesharing processes.

       Caution: incorrect use of SCHED_DG_FIFO or SCHED_DG_LIFO may result
       in severe performance degradation, including the appearance of a
       system hang.

   Note
        * This routine is based on POSIX realtime extension document P1003.4
          draft 14. It is therefore subject to change.

        * Compilation of a source file using this routine requires that
          feature macro _POSIX4_DRAFT_SOURCE be defined.  This feature macro
          is not enabled by any other feature macro, nor does it enable any
          other feature macro.

        * The compiled routine must be linked to library librte.a.

RETURN VALUE
       If successful, schedsetscheduler returns the previous scheduling
       policy of pid. If unsuccessful, the routine returns -1 and sets ERRNO
       to one of the following:

        EFAULT The address of priority is bad.

        EINVAL The value of policy is invalid, or the value in
               schedpriority is outside the range defined for policy.

        EPERM  The caller does not have permission to set the scheduling
               parameters for pid.

        ESRCH  Process pid doesn't exist or is negative.

SEE ALSO
       dgprocessinfo(2), nice(1), nice(2), ps(1), schedgetscheduler(2),
       schedsetparam(2), schedgetparam(2), schedyield(2),
       schedgetprioritymax(2), schedgetprioritymin(2),
       schedrrgetinterval(2), appropriateprivilege(5).
       capdefaults(5).


Licensed material--property of copyright holder(s)

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