Sets scheduling parameters.
Standard C Library (libc.a)
#include <sched.h>
int sched_setparam (pid, param)
pid_t pid;
const struct sched_param *param;
The sched_setparam subroutine sets the scheduling parameters of the process specified by the pid parameter to the values specified by the sched_param structure pointed to by the param parameter. The value of the sched_priority member in the sched_param structure is any integer within the inclusive priority range for the current scheduling policy. Higher numerical values for the priority represent higher priorities.
If a process specified by the pid parameter exists, and if the calling process has permission, the scheduling parameters are set for the process whose process ID is equal to the value of the pid parameter.
If the pid parameter is zero, the scheduling parameters are set for the calling process.
If the caller is favoring a process, it must have SET_PROC_RAC authority. The caller should have the same effective or real user id or BYPASS_DAC_WRITE authority to modify the priority of the process.
Implementations may require the requesting process to have the appropriate authority to set its own scheduling parameters or those of another process.
The target process, whether it is running or not running, is moved to the end of the thread list for its priority.
If the priority of the process specified by the pid parameter is set higher than that of the lowest priority running process and if the specified process is ready to run, the process specified by the pid parameter preempts the lowest priority running process. Similarly, if the process calling the sched_setparam subroutine sets its own priority lower than that of one or more other non-empty process lists, the process that is the head of the highest priority list also preempts the calling process. Thus, the originating process might not receive notification of the completion of the requested priority change until the higher priority process has executed.
Other scheduling policies (such as, SCHED_FIFO2, SCHED_FIFO3, SCHED_FIFO4) behave like fixed priority scheduling policies (such as, SCHED_FIFO and SCHED_RR).
If an implementation supports a two-level scheduling model in which library threads are multiplexed on top of several kernel-scheduled entities, the underlying kernel-scheduled entities for the system contention scope threads are not affected by the sched_setparam subroutine.
The underlying kernel-scheduled entities for the process contention scope threads will have their scheduling parameters changed to the value specified in the param parameter. Kernel-scheduled entities for use by process contention scope threads created after this call completes inherit their scheduling policy and associated scheduling parameters from the process.
The sched_setparam subroutine is not atomic with respect to other threads in the process. Threads might continue to execute while this subroutine call is in the process of changing the scheduling policy for the underlying kernel-scheduled entities.
Item | Description |
---|---|
pid | Specifies the process for which the scheduling parameter is set. |
param | Points to the sched_param structure. |
If successful, the sched_setparam subroutine returns zero.
If the sched_setparam subroutine is unsuccessful, the priority remains unchanged, and the subroutine returns a value of -1 and sets errno to indicate the error.
Item | Description |
---|---|
EINVAL | One or more of the requested scheduling parameters is outside the range defined for the scheduling policy of the specified process ID. |
EINVAL | The param parameter is null or a bad address |
ENOTSUP | This interface does not support processes capable of checkpoint. |
EPERM | The requesting process does not have permission to set the scheduling parameters for the specified process, or does not have the appropriate authority to invoke the sched_setparam subroutine. |
ESRCH | The pid parameter is negative, or no process can be found that corresponds to the one specified by the pid parameter. |