186d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/sys/sched_setparam.2,v 1.4.2.8 2001/12/14 18:34:01 ru Exp $ 286d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/sys/sched_setparam.2,v 1.3 2006/04/08 07:23:35 swildner Exp $ 386d7f5d3SJohn Marino.\" Copyright (c) 1998 HD Associates, Inc. 486d7f5d3SJohn Marino.\" All rights reserved. 586d7f5d3SJohn Marino.\" 686d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 786d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 886d7f5d3SJohn Marino.\" are met: 986d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 1086d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1186d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1286d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1386d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1486d7f5d3SJohn Marino.\" 1586d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1686d7f5d3SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1786d7f5d3SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1886d7f5d3SJohn Marino.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1986d7f5d3SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2086d7f5d3SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2186d7f5d3SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2286d7f5d3SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2386d7f5d3SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2486d7f5d3SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2586d7f5d3SJohn Marino.\" SUCH DAMAGE. 2686d7f5d3SJohn Marino.\" 2786d7f5d3SJohn Marino.Dd March 12, 1998 2886d7f5d3SJohn Marino.Dt SCHED_SETPARAM 2 2986d7f5d3SJohn Marino.Os 3086d7f5d3SJohn Marino.Sh NAME 3186d7f5d3SJohn Marino.Nm sched_setparam , 3286d7f5d3SJohn Marino.Nm sched_getparam 3386d7f5d3SJohn Marino.Nd set/get scheduling parameters 3486d7f5d3SJohn Marino.Sh LIBRARY 3586d7f5d3SJohn Marino.Lb libc 3686d7f5d3SJohn Marino.Sh SYNOPSIS 3786d7f5d3SJohn Marino.In sched.h 3886d7f5d3SJohn Marino.Ft int 3986d7f5d3SJohn Marino.Fn sched_setparam "pid_t pid" "const struct sched_param *param" 4086d7f5d3SJohn Marino.Ft int 4186d7f5d3SJohn Marino.Fn sched_getparam "pid_t pid" "struct sched_param *param" 4286d7f5d3SJohn Marino.Sh DESCRIPTION 4386d7f5d3SJohn MarinoThe 4486d7f5d3SJohn Marino.Fn sched_setparam 4586d7f5d3SJohn Marinofunction sets the scheduling parameters of the process specified by 4686d7f5d3SJohn Marino.Fa pid 4786d7f5d3SJohn Marinoto the values specified by the 4886d7f5d3SJohn Marino.Fa sched_param 4986d7f5d3SJohn Marinostructure pointed to by 5086d7f5d3SJohn Marino.Fa param . 5186d7f5d3SJohn MarinoThe value of the 5286d7f5d3SJohn Marino.Fa sched_priority 5386d7f5d3SJohn Marinomember in the 5486d7f5d3SJohn Marino.Fa param 5586d7f5d3SJohn Marinostructure must be any integer within the inclusive priority range for 5686d7f5d3SJohn Marinothe current scheduling policy of the process specified by 5786d7f5d3SJohn Marino.Fa pid . 5886d7f5d3SJohn MarinoHigher numerical values for the priority represent higher priorities. 5986d7f5d3SJohn Marino.Pp 6086d7f5d3SJohn MarinoIn this implementation, if the value of 6186d7f5d3SJohn Marino.Fa pid 6286d7f5d3SJohn Marinois negative the function will fail. 6386d7f5d3SJohn Marino.Pp 6486d7f5d3SJohn MarinoIf a process specified by 6586d7f5d3SJohn Marino.Fa pid 6686d7f5d3SJohn Marinoexists and if the calling process has permission, the scheduling 6786d7f5d3SJohn Marinoparameters are set for the process whose process ID is equal to 6886d7f5d3SJohn Marino.Fa pid . 6986d7f5d3SJohn Marino.Pp 7086d7f5d3SJohn MarinoIf 7186d7f5d3SJohn Marino.Fa pid 7286d7f5d3SJohn Marinois zero, the scheduling parameters are set for the calling process. 7386d7f5d3SJohn Marino.Pp 7486d7f5d3SJohn MarinoIn this implementation, the policy of when a process can affect 7586d7f5d3SJohn Marinothe scheduling parameters of another process is specified in 7686d7f5d3SJohn Marino.St -p1003.1b-93 7786d7f5d3SJohn Marinoas a write-style operation. 7886d7f5d3SJohn Marino.Pp 7986d7f5d3SJohn MarinoThe target process, whether it is running or not running, will resume 8086d7f5d3SJohn Marinoexecution after all other runnable processes of equal or greater 8186d7f5d3SJohn Marinopriority have been scheduled to run. 8286d7f5d3SJohn Marino.Pp 8386d7f5d3SJohn MarinoIf the priority of the process specified by the 8486d7f5d3SJohn Marino.Fa pid 8586d7f5d3SJohn Marinoargument is set higher than that of the lowest priority running process 8686d7f5d3SJohn Marinoand if the specified process is ready to run, the process specified by 8786d7f5d3SJohn Marinothe 8886d7f5d3SJohn Marino.Fa pid 8986d7f5d3SJohn Marinoargument will preempt a lowest priority running process. Similarly, if 9086d7f5d3SJohn Marinothe process calling 9186d7f5d3SJohn Marino.Fn sched_setparam 9286d7f5d3SJohn Marinosets its own priority lower than that of one or more other nonempty 9386d7f5d3SJohn Marinoprocess lists, then the process that is the head of the highest priority 9486d7f5d3SJohn Marinolist will also preempt the calling process. Thus, in either case, the 9586d7f5d3SJohn Marinooriginating process might not receive notification of the completion of 9686d7f5d3SJohn Marinothe requested priority change until the higher priority process has 9786d7f5d3SJohn Marinoexecuted. 9886d7f5d3SJohn Marino.Pp 9986d7f5d3SJohn MarinoIn this implementation, when the current scheduling policy for the 10086d7f5d3SJohn Marinoprocess specified by 10186d7f5d3SJohn Marino.Fa pid 10286d7f5d3SJohn Marinois normal timesharing (SCHED_OTHER, aka SCHED_NORMAL when not POSIX-source) 10386d7f5d3SJohn Marinoor the idle policy (SCHED_IDLE when not POSIX-source) then the behavior 10486d7f5d3SJohn Marinois as if the process had been running under SCHED_RR with a priority 10586d7f5d3SJohn Marinolower than any actual realtime priority. 10686d7f5d3SJohn Marino.Pp 10786d7f5d3SJohn MarinoThe 10886d7f5d3SJohn Marino.Fn sched_getparam 10986d7f5d3SJohn Marinofunction will return the scheduling parameters of a process specified 11086d7f5d3SJohn Marinoby 11186d7f5d3SJohn Marino.Fa pid 11286d7f5d3SJohn Marinoin the 11386d7f5d3SJohn Marino.Fa sched_param 11486d7f5d3SJohn Marinostructure pointed to by 11586d7f5d3SJohn Marino.Fa param . 11686d7f5d3SJohn Marino.Pp 11786d7f5d3SJohn MarinoIf a process specified by 11886d7f5d3SJohn Marino.Fa pid 11986d7f5d3SJohn Marinoexists and if the calling process has permission, 12086d7f5d3SJohn Marinothe scheduling parameters for the process whose process ID is equal to 12186d7f5d3SJohn Marino.Fa pid 12286d7f5d3SJohn Marinoare returned. 12386d7f5d3SJohn Marino.Pp 12486d7f5d3SJohn MarinoIn this implementation, the policy of when a process can obtain the 12586d7f5d3SJohn Marinoscheduling parameters of another process are detailed in 12686d7f5d3SJohn Marino.St -p1003.1b-93 12786d7f5d3SJohn Marinoas a read-style operation. 12886d7f5d3SJohn Marino.Pp 12986d7f5d3SJohn MarinoIf 13086d7f5d3SJohn Marino.Fa pid 13186d7f5d3SJohn Marinois zero, the scheduling parameters for the calling process will be 13286d7f5d3SJohn Marinoreturned. In this implementation, the 13386d7f5d3SJohn Marino.Fa sched_getparam 13486d7f5d3SJohn Marinofunction will fail if 13586d7f5d3SJohn Marino.Fa pid 13686d7f5d3SJohn Marinois negative. 13786d7f5d3SJohn Marino.Sh RETURN VALUES 13886d7f5d3SJohn Marino.Rv -std 13986d7f5d3SJohn Marino.Sh ERRORS 14086d7f5d3SJohn MarinoOn failure 14186d7f5d3SJohn Marino.Va errno 14286d7f5d3SJohn Marinowill be set to the corresponding value: 14386d7f5d3SJohn Marino.Bl -tag -width Er 14486d7f5d3SJohn Marino.It Bq Er ENOSYS 14586d7f5d3SJohn MarinoThe system is not configured to support this functionality. 14686d7f5d3SJohn Marino.It Bq Er EPERM 14786d7f5d3SJohn MarinoThe requesting process doesn not have permission as detailed in 14886d7f5d3SJohn Marino.St -p1003.1b-93 . 14986d7f5d3SJohn Marino.It Bq Er ESRCH 15086d7f5d3SJohn MarinoNo process can be found corresponding to that specified by 15186d7f5d3SJohn Marino.Fa pid . 15286d7f5d3SJohn Marino.It Bq Er EINVAL 15386d7f5d3SJohn MarinoFor 15486d7f5d3SJohn Marino.Fn sched_setparam : 15586d7f5d3SJohn Marinoone or more of the requested scheduling parameters 15686d7f5d3SJohn Marinois outside the range defined for the scheduling policy of the specified 15786d7f5d3SJohn Marino.Fa pid . 15886d7f5d3SJohn Marino.El 15986d7f5d3SJohn Marino.Sh SEE ALSO 16086d7f5d3SJohn Marino.Xr sched_getscheduler 2 , 16186d7f5d3SJohn Marino.Xr sched_get_priority_max 2 , 16286d7f5d3SJohn Marino.Xr sched_get_priority_min 2 , 16386d7f5d3SJohn Marino.Xr sched_rr_get_interval 2 , 16486d7f5d3SJohn Marino.Xr sched_setscheduler 2 , 16586d7f5d3SJohn Marino.Xr sched_yield 2 16686d7f5d3SJohn Marino.Sh STANDARDS 16786d7f5d3SJohn MarinoThe 16886d7f5d3SJohn Marino.Fn sched_setparam 16986d7f5d3SJohn Marinoand 17086d7f5d3SJohn Marino.Fn sched_getparam 17186d7f5d3SJohn Marinofunctions conform to 17286d7f5d3SJohn Marino.St -p1003.1b-93 . 173