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