xref: /dflybsd-src/lib/libc/sys/sched_setscheduler.2 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/sys/sched_setscheduler.2,v 1.3.2.9 2001/12/14 18:34:01 ru Exp $
286d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/sys/sched_setscheduler.2,v 1.6 2008/05/25 18:11:47 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_SETSCHEDULER 2
2986d7f5d3SJohn Marino.Os
3086d7f5d3SJohn Marino.Sh NAME
3186d7f5d3SJohn Marino.Nm sched_setscheduler ,
3286d7f5d3SJohn Marino.Nm sched_getscheduler
3386d7f5d3SJohn Marino.Nd set/get scheduling policy and scheduler 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_setscheduler "pid_t pid" "int policy" "const struct sched_param *param"
4086d7f5d3SJohn Marino.Ft int
4186d7f5d3SJohn Marino.Fn sched_getscheduler "pid_t pid"
4286d7f5d3SJohn Marino.Sh DESCRIPTION
4386d7f5d3SJohn MarinoThe
4486d7f5d3SJohn Marino.Fn sched_setscheduler
4586d7f5d3SJohn Marinofunction sets the scheduling policy and scheduling parameters
4686d7f5d3SJohn Marinoof the process specified by
4786d7f5d3SJohn Marino.Fa pid
4886d7f5d3SJohn Marinoto
4986d7f5d3SJohn Marino.Fa policy
5086d7f5d3SJohn Marinoand the parameters specified in the
5186d7f5d3SJohn Marino.Fa sched_param
5286d7f5d3SJohn Marinostructure pointed to by
5386d7f5d3SJohn Marino.Fa param ,
5486d7f5d3SJohn Marinorespectively.
5586d7f5d3SJohn MarinoThe value of the
5686d7f5d3SJohn Marino.Fa sched_priority
5786d7f5d3SJohn Marinomember in the
5886d7f5d3SJohn Marino.Fa param
5986d7f5d3SJohn Marinostructure must be any integer within the inclusive priority range for
6086d7f5d3SJohn Marinothe scheduling policy specified by
6186d7f5d3SJohn Marino.Fa policy .
6286d7f5d3SJohn Marino.Pp
6386d7f5d3SJohn MarinoIn this implementation, if the value of
6486d7f5d3SJohn Marino.Fa pid
6586d7f5d3SJohn Marinois negative the function will fail.
6686d7f5d3SJohn Marino.Pp
6786d7f5d3SJohn MarinoIf a process specified by
6886d7f5d3SJohn Marino.Fa pid
6986d7f5d3SJohn Marinoexists and if the calling process has permission, the scheduling
7086d7f5d3SJohn Marinopolicy and scheduling parameters will be set for the process
7186d7f5d3SJohn Marinowhose process ID is equal to
7286d7f5d3SJohn Marino.Fa pid .
7386d7f5d3SJohn Marino.Pp
7486d7f5d3SJohn MarinoIf
7586d7f5d3SJohn Marino.Fa pid
7686d7f5d3SJohn Marinois zero, the scheduling policy and scheduling
7786d7f5d3SJohn Marinoparameters are set for the calling process.
7886d7f5d3SJohn Marino.Pp
7986d7f5d3SJohn MarinoIn this implementation, the policy of when a process can affect
8086d7f5d3SJohn Marinothe scheduling parameters of another process is specified in
8186d7f5d3SJohn Marino.St -p1003.1b-93
8286d7f5d3SJohn Marinoas a write-style operation.
8386d7f5d3SJohn Marino.Pp
8486d7f5d3SJohn MarinoThe scheduling policies are in
8586d7f5d3SJohn Marino.In sched.h :
8686d7f5d3SJohn Marino.Bl -tag -width ".Dv SCHED_OTHER"
8786d7f5d3SJohn Marino.It Dv SCHED_FIFO
8886d7f5d3SJohn MarinoFirst-in-first-out fixed priority scheduling with no round robin scheduling;
8986d7f5d3SJohn Marino.It Dv SCHED_OTHER
9086d7f5d3SJohn MarinoThe standard time sharing scheduler;
9186d7f5d3SJohn Marino.It Dv SCHED_RR
9286d7f5d3SJohn MarinoRound-robin scheduling across same priority processes.
9386d7f5d3SJohn Marino.El
9486d7f5d3SJohn Marino.Pp
9586d7f5d3SJohn MarinoThe
9686d7f5d3SJohn Marino.Fa sched_param
9786d7f5d3SJohn Marinostructure is defined in
9886d7f5d3SJohn Marino.In sched.h :
9986d7f5d3SJohn Marino.Bd -literal -offset indent
10086d7f5d3SJohn Marinostruct sched_param {
10186d7f5d3SJohn Marino	int sched_priority;	/* scheduling priority */
10286d7f5d3SJohn Marino};
10386d7f5d3SJohn Marino.Ed
10486d7f5d3SJohn Marino.Pp
10586d7f5d3SJohn MarinoThe
10686d7f5d3SJohn Marino.Fn sched_getscheduler
10786d7f5d3SJohn Marinofunction returns the scheduling policy of the process specified
10886d7f5d3SJohn Marinoby
10986d7f5d3SJohn Marino.Fa pid .
11086d7f5d3SJohn Marino.Pp
11186d7f5d3SJohn MarinoIf a process specified by
11286d7f5d3SJohn Marino.Fa pid
11386d7f5d3SJohn Marinoexists and if the calling process has permission,
11486d7f5d3SJohn Marinothe scheduling parameters for the process whose process ID is equal to
11586d7f5d3SJohn Marino.Fa pid
11686d7f5d3SJohn Marinoare returned.
11786d7f5d3SJohn Marino.Pp
11886d7f5d3SJohn MarinoIn this implementation, the policy of when a process can obtain the
11986d7f5d3SJohn Marinoscheduling parameters of another process are detailed in
12086d7f5d3SJohn Marino.St -p1003.1b-93
12186d7f5d3SJohn Marinoas a read-style operation.
12286d7f5d3SJohn Marino.Pp
12386d7f5d3SJohn MarinoIf
12486d7f5d3SJohn Marino.Fa pid
12586d7f5d3SJohn Marinois zero, the scheduling parameters for the calling process will be
12686d7f5d3SJohn Marinoreturned.  In this implementation, the
12786d7f5d3SJohn Marino.Fa sched_getscheduler
12886d7f5d3SJohn Marinofunction will fail if
12986d7f5d3SJohn Marino.Fa pid
13086d7f5d3SJohn Marinois negative.
13186d7f5d3SJohn Marino.Sh RETURN VALUES
13286d7f5d3SJohn Marino.Rv -std
13386d7f5d3SJohn Marino.Sh ERRORS
13486d7f5d3SJohn MarinoOn failure
13586d7f5d3SJohn Marino.Va errno
13686d7f5d3SJohn Marinowill be set to the corresponding value:
13786d7f5d3SJohn Marino.Bl -tag -width Er
13886d7f5d3SJohn Marino.It Bq Er ENOSYS
13986d7f5d3SJohn MarinoThe system is not configured to support this functionality.
14086d7f5d3SJohn Marino.It Bq Er EPERM
14186d7f5d3SJohn MarinoThe requesting process doesn not have permission as detailed in
14286d7f5d3SJohn Marino.St -p1003.1b-93 .
14386d7f5d3SJohn Marino.It Bq Er ESRCH
14486d7f5d3SJohn MarinoNo process can be found corresponding to that specified by
14586d7f5d3SJohn Marino.Fa pid .
14686d7f5d3SJohn Marino.It Bq Er EINVAL
14786d7f5d3SJohn MarinoThe value of the
14886d7f5d3SJohn Marino.Fa policy
14986d7f5d3SJohn Marinoparameter is invalid, or one or more of the parameters contained in
15086d7f5d3SJohn Marino.Fa param
15186d7f5d3SJohn Marinois outside the valid range for the specified scheduling policy.
15286d7f5d3SJohn Marino.El
15386d7f5d3SJohn Marino.Sh SEE ALSO
15486d7f5d3SJohn Marino.Xr sched_getparam 2 ,
15586d7f5d3SJohn Marino.Xr sched_get_priority_max 2 ,
15686d7f5d3SJohn Marino.Xr sched_get_priority_min 2 ,
15786d7f5d3SJohn Marino.Xr sched_rr_get_interval 2 ,
15886d7f5d3SJohn Marino.Xr sched_setparam 2 ,
15986d7f5d3SJohn Marino.Xr sched_yield 2
16086d7f5d3SJohn Marino.Sh STANDARDS
16186d7f5d3SJohn MarinoThe
16286d7f5d3SJohn Marino.Fn sched_setscheduler
16386d7f5d3SJohn Marinoand
16486d7f5d3SJohn Marino.Fn sched_getscheduler
16586d7f5d3SJohn Marinofunctions conform to
16686d7f5d3SJohn Marino.St -p1003.1b-93 .
167