1.\" Copyright (c) 1998 HD Associates, Inc. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd March 12, 1998 26.Dt SCHED_SETSCHEDULER 2 27.Os 28.Sh NAME 29.Nm sched_setscheduler , 30.Nm sched_getscheduler 31.Nd set/get scheduling policy and scheduler parameters 32.Sh LIBRARY 33.Lb libc 34.Sh SYNOPSIS 35.In sched.h 36.Ft int 37.Fn sched_setscheduler "pid_t pid" "int policy" "const struct sched_param *param" 38.Ft int 39.Fn sched_getscheduler "pid_t pid" 40.Sh DESCRIPTION 41The 42.Fn sched_setscheduler 43system call sets the scheduling policy and scheduling parameters 44of the process specified by 45.Fa pid 46to 47.Fa policy 48and the parameters specified in the 49.Vt sched_param 50structure pointed to by 51.Fa param , 52respectively. 53The value of the 54.Fa sched_priority 55member in the 56.Fa param 57structure must be any integer within the inclusive priority range for 58the scheduling policy specified by 59.Fa policy . 60.Pp 61In this implementation, if the value of 62.Fa pid 63is negative the system call will fail. 64.Pp 65If a process specified by 66.Fa pid 67exists and if the calling process has permission, the scheduling 68policy and scheduling parameters will be set for the process 69whose process ID is equal to 70.Fa pid . 71.Pp 72If 73.Fa pid 74is zero, the scheduling policy and scheduling 75parameters are set for the calling process. 76.Pp 77In this implementation, the policy of when a process can affect 78the scheduling parameters of another process is specified in 79.St -p1003.1b-93 80as a write-style operation. 81.Pp 82The scheduling policies are in 83.Fa <sched.h> : 84.Bl -tag -width [SCHED_OTHER] 85.It Bq Er SCHED_FIFO 86First-in-first-out fixed priority scheduling with no round robin scheduling; 87.It Bq Er SCHED_OTHER 88The standard time sharing scheduler; 89.It Bq Er SCHED_RR 90Round-robin scheduling across same priority processes. 91.El 92.Pp 93The 94.Vt sched_param 95structure is defined in 96.Fa <sched.h> : 97.Bd -literal -offset indent 98struct sched_param { 99 int sched_priority; /* scheduling priority */ 100}; 101.Ed 102.Pp 103The 104.Fn sched_getscheduler 105system call returns the scheduling policy of the process specified 106by 107.Fa pid . 108.Pp 109If a process specified by 110.Fa pid 111exists and if the calling process has permission, 112the scheduling parameters for the process whose process ID is equal to 113.Fa pid 114are returned. 115.Pp 116In this implementation, the policy of when a process can obtain the 117scheduling parameters of another process are detailed in 118.St -p1003.1b-93 119as a read-style operation. 120.Pp 121If 122.Fa pid 123is zero, the scheduling parameters for the calling process will be 124returned. 125In this implementation, the 126.Fa sched_getscheduler 127system call will fail if 128.Fa pid 129is negative. 130.Sh RETURN VALUES 131.Rv -std 132.Sh ERRORS 133On failure 134.Va errno 135will be set to the corresponding value: 136.Bl -tag -width Er 137.It Bq Er ENOSYS 138The system is not configured to support this functionality. 139.It Bq Er EPERM 140The requesting process doesn not have permission as detailed in 141.St -p1003.1b-93 . 142.It Bq Er ESRCH 143No process can be found corresponding to that specified by 144.Fa pid . 145.It Bq Er EINVAL 146The value of the 147.Fa policy 148argument is invalid, or one or more of the parameters contained in 149.Fa param 150is outside the valid range for the specified scheduling policy. 151.El 152.Sh SEE ALSO 153.Xr sched_get_priority_max 2 , 154.Xr sched_get_priority_min 2 , 155.Xr sched_getparam 2 , 156.Xr sched_rr_get_interval 2 , 157.Xr sched_setparam 2 , 158.Xr sched_yield 2 159.Sh STANDARDS 160The 161.Fn sched_setscheduler 162and 163.Fn sched_getscheduler 164system calls conform to 165.St -p1003.1b-93 . 166