xref: /dragonfly/lib/libc/sys/sched_setscheduler.2 (revision 0554b2fc)
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.6 2008/05/25 18:11:47 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 ".Dv SCHED_OTHER"
87.It Dv SCHED_FIFO
88First-in-first-out fixed priority scheduling with no round robin scheduling;
89.It Dv SCHED_OTHER
90The standard time sharing scheduler;
91.It Dv 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.Bd -literal -offset indent
100struct sched_param {
101	int sched_priority;	/* scheduling priority */
102};
103.Ed
104.Pp
105The
106.Fn sched_getscheduler
107function returns the scheduling policy of the process specified
108by
109.Fa pid .
110.Pp
111If a process specified by
112.Fa pid
113exists and if the calling process has permission,
114the scheduling parameters for the process whose process ID is equal to
115.Fa pid
116are returned.
117.Pp
118In this implementation, the policy of when a process can obtain the
119scheduling parameters of another process are detailed in
120.St -p1003.1b-93
121as a read-style operation.
122.Pp
123If
124.Fa pid
125is zero, the scheduling parameters for the calling process will be
126returned.  In this implementation, the
127.Fa sched_getscheduler
128function will fail if
129.Fa pid
130is negative.
131.Sh RETURN VALUES
132.Rv -std
133.Sh ERRORS
134On failure
135.Va errno
136will be set to the corresponding value:
137.Bl -tag -width Er
138.It Bq Er ENOSYS
139The system is not configured to support this functionality.
140.It Bq Er EPERM
141The requesting process doesn not have permission as detailed in
142.St -p1003.1b-93 .
143.It Bq Er ESRCH
144No process can be found corresponding to that specified by
145.Fa pid .
146.It Bq Er EINVAL
147The value of the
148.Fa policy
149parameter is invalid, or one or more of the parameters contained in
150.Fa param
151is outside the valid range for the specified scheduling policy.
152.El
153.Sh SEE ALSO
154.Xr sched_getparam 2 ,
155.Xr sched_get_priority_max 2 ,
156.Xr sched_get_priority_min 2 ,
157.Xr sched_rr_get_interval 2 ,
158.Xr sched_setparam 2 ,
159.Xr sched_yield 2
160.Sh STANDARDS
161The
162.Fn sched_setscheduler
163and
164.Fn sched_getscheduler
165functions conform to
166.St -p1003.1b-93 .
167