]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/sched_rr_get_interval.2
f57c2307bdc367a019bf8f59426af7344959c2e8
[thirdparty/man-pages.git] / man2 / sched_rr_get_interval.2
1 .\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996
2 .\"
3 .\" SPDX-License-Identifier: GPL-2.0-or-later
4 .\"
5 .\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
6 .\" First version written
7 .\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
8 .\" revision
9 .\"
10 .TH SCHED_RR_GET_INTERVAL 2 2021-03-22 "Linux" "Linux Programmer's Manual"
11 .SH NAME
12 sched_rr_get_interval \- get the SCHED_RR interval for the named process
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ", " \-lc )
16 .SH SYNOPSIS
17 .nf
18 .B #include <sched.h>
19 .PP
20 .BI "int sched_rr_get_interval(pid_t " pid ", struct timespec *" tp );
21 .fi
22 .SH DESCRIPTION
23 .BR sched_rr_get_interval ()
24 writes into the
25 .BR timespec (3)
26 structure pointed to by
27 .I tp
28 the round-robin time quantum for the process identified by
29 .IR pid .
30 The specified process should be running under the
31 .B SCHED_RR
32 scheduling policy.
33 .PP
34 If
35 .I pid
36 is zero, the time quantum for the calling process is written into
37 .IR *tp .
38 .\" FIXME . On Linux, sched_rr_get_interval()
39 .\" returns the timeslice for SCHED_OTHER processes -- this timeslice
40 .\" is influenced by the nice value.
41 .\" For SCHED_FIFO processes, this always returns 0.
42 .\"
43 .\" The round-robin time quantum value is not alterable under Linux
44 .\" 1.3.81.
45 .\"
46 .SH RETURN VALUE
47 On success,
48 .BR sched_rr_get_interval ()
49 returns 0.
50 On error, \-1 is returned, and
51 .I errno
52 is set to indicate the error.
53 .SH ERRORS
54 .TP
55 .B EFAULT
56 Problem with copying information to user space.
57 .TP
58 .B EINVAL
59 Invalid pid.
60 .TP
61 .B ENOSYS
62 The system call is not yet implemented (only on rather old kernels).
63 .TP
64 .B ESRCH
65 Could not find a process with the ID
66 .IR pid .
67 .SH CONFORMING TO
68 POSIX.1-2001, POSIX.1-2008.
69 .SH NOTES
70 POSIX systems on which
71 .BR sched_rr_get_interval ()
72 is available define
73 .B _POSIX_PRIORITY_SCHEDULING
74 in
75 .IR <unistd.h> .
76 .SS Linux notes
77 POSIX does not specify any mechanism for controlling the size of the
78 round-robin time quantum.
79 Older Linux kernels provide a (nonportable) method of doing this.
80 The quantum can be controlled by adjusting the process's nice value (see
81 .BR setpriority (2)).
82 Assigning a negative (i.e., high) nice value results in a longer quantum;
83 assigning a positive (i.e., low) nice value results in a shorter quantum.
84 The default quantum is 0.1 seconds;
85 the degree to which changing the nice value affects the
86 quantum has varied somewhat across kernel versions.
87 This method of adjusting the quantum was removed
88 .\" commit a4ec24b48ddef1e93f7578be53270f0b95ad666c
89 starting with Linux 2.6.24.
90 .PP
91 Linux 3.9 added
92 .\" commit ce0dbbbb30aee6a835511d5be446462388ba9eee
93 a new mechanism for adjusting (and viewing) the
94 .BR SCHED_RR
95 quantum: the
96 .I /proc/sys/kernel/sched_rr_timeslice_ms
97 file exposes the quantum as a millisecond value, whose default is 100.
98 Writing 0 to this file resets the quantum to the default value.
99 .\" .SH BUGS
100 .\" As of Linux 1.3.81
101 .\" .BR sched_rr_get_interval ()
102 .\" returns with error
103 .\" ENOSYS, because SCHED_RR has not yet been fully implemented and tested
104 .\" properly.
105 .SH SEE ALSO
106 .BR timespec (3),
107 .BR sched (7)