1*8269e767SBrooks Davis.\" Copyright (c) 1998 HD Associates, Inc. 2*8269e767SBrooks Davis.\" All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 11*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 12*8269e767SBrooks Davis.\" 13*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*8269e767SBrooks Davis.\" SUCH DAMAGE. 24*8269e767SBrooks Davis.\" 25*8269e767SBrooks Davis.Dd March 12, 1998 26*8269e767SBrooks Davis.Dt SCHED_SETPARAM 2 27*8269e767SBrooks Davis.Os 28*8269e767SBrooks Davis.Sh NAME 29*8269e767SBrooks Davis.Nm sched_setparam , 30*8269e767SBrooks Davis.Nm sched_getparam 31*8269e767SBrooks Davis.Nd set/get scheduling parameters 32*8269e767SBrooks Davis.Sh LIBRARY 33*8269e767SBrooks Davis.Lb libc 34*8269e767SBrooks Davis.Sh SYNOPSIS 35*8269e767SBrooks Davis.In sched.h 36*8269e767SBrooks Davis.Ft int 37*8269e767SBrooks Davis.Fn sched_setparam "pid_t pid" "const struct sched_param *param" 38*8269e767SBrooks Davis.Ft int 39*8269e767SBrooks Davis.Fn sched_getparam "pid_t pid" "struct sched_param *param" 40*8269e767SBrooks Davis.Sh DESCRIPTION 41*8269e767SBrooks DavisThe 42*8269e767SBrooks Davis.Fn sched_setparam 43*8269e767SBrooks Davissystem call sets the scheduling parameters of the process specified by 44*8269e767SBrooks Davis.Fa pid 45*8269e767SBrooks Davisto the values specified by the 46*8269e767SBrooks Davis.Fa sched_param 47*8269e767SBrooks Davisstructure pointed to by 48*8269e767SBrooks Davis.Fa param . 49*8269e767SBrooks DavisThe value of the 50*8269e767SBrooks Davis.Fa sched_priority 51*8269e767SBrooks Davismember in the 52*8269e767SBrooks Davis.Fa param 53*8269e767SBrooks Davisstructure must be any integer within the inclusive priority range for 54*8269e767SBrooks Davisthe current scheduling policy of the process specified by 55*8269e767SBrooks Davis.Fa pid . 56*8269e767SBrooks DavisHigher numerical values for the priority represent higher priorities. 57*8269e767SBrooks Davis.Pp 58*8269e767SBrooks DavisIn this implementation, if the value of 59*8269e767SBrooks Davis.Fa pid 60*8269e767SBrooks Davisis negative the system call will fail. 61*8269e767SBrooks Davis.Pp 62*8269e767SBrooks DavisIf a process specified by 63*8269e767SBrooks Davis.Fa pid 64*8269e767SBrooks Davisexists and if the calling process has permission, the scheduling 65*8269e767SBrooks Davisparameters are set for the process whose process ID is equal to 66*8269e767SBrooks Davis.Fa pid . 67*8269e767SBrooks Davis.Pp 68*8269e767SBrooks DavisIf 69*8269e767SBrooks Davis.Fa pid 70*8269e767SBrooks Davisis zero, the scheduling parameters are set for the calling process. 71*8269e767SBrooks Davis.Pp 72*8269e767SBrooks DavisIn this implementation, the policy of when a process can affect 73*8269e767SBrooks Davisthe scheduling parameters of another process is specified in 74*8269e767SBrooks Davis.St -p1003.1b-93 75*8269e767SBrooks Davisas a write-style operation. 76*8269e767SBrooks Davis.Pp 77*8269e767SBrooks DavisThe target process, whether it is running or not running, will resume 78*8269e767SBrooks Davisexecution after all other runnable processes of equal or greater 79*8269e767SBrooks Davispriority have been scheduled to run. 80*8269e767SBrooks Davis.Pp 81*8269e767SBrooks DavisIf the priority of the process specified by the 82*8269e767SBrooks Davis.Fa pid 83*8269e767SBrooks Davisargument is set higher than that of the lowest priority running process 84*8269e767SBrooks Davisand if the specified process is ready to run, the process specified by 85*8269e767SBrooks Davisthe 86*8269e767SBrooks Davis.Fa pid 87*8269e767SBrooks Davisargument will preempt a lowest priority running process. 88*8269e767SBrooks DavisSimilarly, if 89*8269e767SBrooks Davisthe process calling 90*8269e767SBrooks Davis.Fn sched_setparam 91*8269e767SBrooks Davissets its own priority lower than that of one or more other nonempty 92*8269e767SBrooks Davisprocess lists, then the process that is the head of the highest priority 93*8269e767SBrooks Davislist will also preempt the calling process. 94*8269e767SBrooks DavisThus, in either case, the 95*8269e767SBrooks Davisoriginating process might not receive notification of the completion of 96*8269e767SBrooks Davisthe requested priority change until the higher priority process has 97*8269e767SBrooks Davisexecuted. 98*8269e767SBrooks Davis.Pp 99*8269e767SBrooks DavisIn this implementation, when the current scheduling policy for the 100*8269e767SBrooks Davisprocess specified by 101*8269e767SBrooks Davis.Fa pid 102*8269e767SBrooks Davisis normal timesharing (SCHED_OTHER, aka SCHED_NORMAL when not POSIX-source) 103*8269e767SBrooks Davisor the idle policy (SCHED_IDLE when not POSIX-source) then the behavior 104*8269e767SBrooks Davisis as if the process had been running under SCHED_RR with a priority 105*8269e767SBrooks Davislower than any actual realtime priority. 106*8269e767SBrooks Davis.Pp 107*8269e767SBrooks DavisThe 108*8269e767SBrooks Davis.Fn sched_getparam 109*8269e767SBrooks Davissystem call will return the scheduling parameters of a process specified 110*8269e767SBrooks Davisby 111*8269e767SBrooks Davis.Fa pid 112*8269e767SBrooks Davisin the 113*8269e767SBrooks Davis.Fa sched_param 114*8269e767SBrooks Davisstructure pointed to by 115*8269e767SBrooks Davis.Fa param . 116*8269e767SBrooks Davis.Pp 117*8269e767SBrooks DavisIf a process specified by 118*8269e767SBrooks Davis.Fa pid 119*8269e767SBrooks Davisexists and if the calling process has permission, 120*8269e767SBrooks Davisthe scheduling parameters for the process whose process ID is equal to 121*8269e767SBrooks Davis.Fa pid 122*8269e767SBrooks Davisare returned. 123*8269e767SBrooks Davis.Pp 124*8269e767SBrooks DavisIn this implementation, the policy of when a process can obtain the 125*8269e767SBrooks Davisscheduling parameters of another process are detailed in 126*8269e767SBrooks Davis.St -p1003.1b-93 127*8269e767SBrooks Davisas a read-style operation. 128*8269e767SBrooks Davis.Pp 129*8269e767SBrooks DavisIf 130*8269e767SBrooks Davis.Fa pid 131*8269e767SBrooks Davisis zero, the scheduling parameters for the calling process will be 132*8269e767SBrooks Davisreturned. 133*8269e767SBrooks DavisIn this implementation, the 134*8269e767SBrooks Davis.Fa sched_getparam 135*8269e767SBrooks Davissystem call will fail if 136*8269e767SBrooks Davis.Fa pid 137*8269e767SBrooks Davisis negative. 138*8269e767SBrooks Davis.Sh RETURN VALUES 139*8269e767SBrooks Davis.Rv -std 140*8269e767SBrooks Davis.Sh ERRORS 141*8269e767SBrooks DavisOn failure 142*8269e767SBrooks Davis.Va errno 143*8269e767SBrooks Daviswill be set to the corresponding value: 144*8269e767SBrooks Davis.Bl -tag -width Er 145*8269e767SBrooks Davis.It Bq Er ENOSYS 146*8269e767SBrooks DavisThe system is not configured to support this functionality. 147*8269e767SBrooks Davis.It Bq Er EPERM 148*8269e767SBrooks DavisThe requesting process doesn not have permission as detailed in 149*8269e767SBrooks Davis.St -p1003.1b-93 . 150*8269e767SBrooks Davis.It Bq Er ESRCH 151*8269e767SBrooks DavisNo process can be found corresponding to that specified by 152*8269e767SBrooks Davis.Fa pid . 153*8269e767SBrooks Davis.It Bq Er EINVAL 154*8269e767SBrooks DavisFor 155*8269e767SBrooks Davis.Fn sched_setparam : 156*8269e767SBrooks Davisone or more of the requested scheduling parameters 157*8269e767SBrooks Davisis outside the range defined for the scheduling policy of the specified 158*8269e767SBrooks Davis.Fa pid . 159*8269e767SBrooks Davis.El 160*8269e767SBrooks Davis.Sh SEE ALSO 161*8269e767SBrooks Davis.Xr sched_get_priority_max 2 , 162*8269e767SBrooks Davis.Xr sched_get_priority_min 2 , 163*8269e767SBrooks Davis.Xr sched_getscheduler 2 , 164*8269e767SBrooks Davis.Xr sched_rr_get_interval 2 , 165*8269e767SBrooks Davis.Xr sched_setscheduler 2 , 166*8269e767SBrooks Davis.Xr sched_yield 2 167*8269e767SBrooks Davis.Sh STANDARDS 168*8269e767SBrooks DavisThe 169*8269e767SBrooks Davis.Fn sched_setparam 170*8269e767SBrooks Davisand 171*8269e767SBrooks Davis.Fn sched_getparam 172*8269e767SBrooks Davissystem calls conform to 173*8269e767SBrooks Davis.St -p1003.1b-93 . 174