Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sched_getscheduler(3P4)

sched_setparam(3P4)

sched_getparam(3P4)

sched_get_priority_max(3P4)

hardclock(1M)

sched_setscheduler(3P4)  —  (M88K only)

NAME

sched_setscheduler − POSIX 1003.4 set scheduling policy for a process

SYNOPSIS

#include <sched.h>

int sched_setscheduler(pid, policy, param)
pid_t pid;
int policy;
struct sched_param ∗param

DESCRIPTION

The sched_setscheduler() function sets the scheduling policy and scheduling parameters of the process specified by pid to policy and the parameters specified in the structure pointed to by param.  The value of sched_priority in the sched_param structure shall be any integer within the priority range for the scheduling policy specified by policy. 

The possible values for the policy parameter are defined in the header file <sched.h> and include:

SCHED_FIFO
a first in-first out (FIFO) scheduling policy.

SCHED_RR
a round robin scheduling policy.

SCHED-OTHER
another scheduling policy.

If a process described by pid exists and if the calling process has permission, the scheduling policy and scheduling parameters are set for the process whose process ID is equal to pid. 

If pid is zero, the scheduling policy and scheduling parameters are set for the calling process. 

For a process to have permission to set the scheduling policy and scheduling parameters of a process designated by pid, the real or effective user ID of the calling process must match the real or effective user ID of the target process unless the calling process is super-user, or the calling process has the ACC_SETPRI bit set in the access vector (if access vectors are configured).  To set the priority of a process to a higher value the user must either be super-user or have the ACC_SETPRI bit set in the access vector (if access vectors are configured). 

The sched_setscheduler() function is considered successful if it succeeds in setting the scheduling policy and scheduling parameters of the process specified by pid to the values specified by policy and the sched_param, structure respectively. 

The SCHED_RR and SCHED_FIFO scheduling policies are real-time scheduling policies.  Processes in the real-time scheduling policies have static priorities; that is, their priorities are not altered by the operating system.  Processes scheduled in the SCHED_RR scheduling policy have an associated time quantum.  When a process’s time quantum expires, the process is moved to the end of the list of processes which are ready to run and have the same priority as the current process.  The highest priority process is then chosen for execution.  Processes scheduled under the SCHED_FIFO scheduling policy do not have a time quantum associated with them.  This means that as long as the process remains the highest priority process on a given CPU, it will continue to execute until it voluntarily blocks. 

A process cannot be scheduled under the SCHED_RR policy on a CPU where the hardclock interrupt is disabled.  No error is returned to a user in this case.  A process that is scheduled under the SCHED_RR policy and runs on a CPU where hardclock is disabled will behave as if it were scheduled under the SCHED_FIFO policy. 

The SCHED_OTHER scheduling policy is used to set a non-real-time scheduling policy if a non-real-time scheduling policy exists in the system.  The interactive scheduling class must be configured for a non-real-time scheduling policy to exist.  When the interactive scheduling class is not configured, the SCHED_OTHER scheduling policy will be identical to SCHED_RR. 

See the CX/RT Reference Manual for a full description of the behavior of a process that is scheduled under the various scheduling policies. 

RETURN VALUE

Upon successful completion, the sched_setscheduler() function returns the former scheduling policy of the specified process.  If the sched_setscheduler function fails to complete successfully, the policy and scheduling parameters remain unchanged; a value of -1 is returned; and errno is set to indicate the error.  Possible errors include:

[EINVAL] An invalid value was specified for the policy parameter; the param pointer is NULL; or the priority contained in the param structure is outside the valid range for the specified scheduling policy. 

[EPERM] The user attempted to set the priority to a higher value and is not super-user or does not have the ACC_SETPRI access vector (if access vectors are configured). 

[EPERM] The user attempted to change the priority of another process and does not have an effective user ID that matches the real or effective user ID of the target process, is not super-user, and does not have the ACC_SETPRI access vector (if access vectors are configured). 

[ESRCH] No process can be found corresponding to that specified by pid. 

FILES

/usr/lib/libposix4.a

SEE ALSO

sched_getscheduler(3P4), sched_setparam(3P4), sched_getparam(3P4), sched_get_priority_max(3P4), hardclock(1M), CX/RT Reference Manual. 

WARNING

The interface to sched_setscheduler() is based on IEEE Draft Standard P1003.4/D12.  This is an unapproved draft, subject to change.  Use of information contained in this unapproved draft is at your own risk.  This interface will change to reflect any changes made by future drafts of POSIX 1003.4. 

CX/UX Programmer’s Reference Manual

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