sched_rr_get_interval(2)
π sched_rr_get_interval(2) π
okay bestie, listen up β this is a page from the System Calls Manual, and it's about sched_rr_get_interval, aka "hey kernel, how long does my round-robin slice actually last?" π It lives in the Standard C library (libc, -lc), so it's basically part of your everyday toolkit fr fr.
β¨ NAME β¨
sched_rr_get_interval β get the SCHED_RR interval for the named process π
π LIBRARY π
Standard C library (libc, -lc) β the standard issue, no extra download needed, we love that for us π«Ά
πΈ SYNOPSIS πΈ
#include <sched.h>
int sched_rr_get_interval(pid_t pid, struct timespec *tp);
π¦ DESCRIPTION π¦
so what does it actually do? It writes the round-robin time quantum into the timespec(3) structure that tp points at, and that quantum belongs to the process identified by pid. Simple as.
heads up: the process you're asking about should be running under the SCHED_RR scheduling policy. Otherwise, like, why are you even here π
And if pid is zero? Cute question. That means the time quantum for the calling process gets written into *tp. Self-care, honestly π
π« RETURN VALUE π«
- On success,
sched_rr_get_interval()returns0. Slay. β¨ - On error,
-1is returned, anderrnois set to tell you exactly what went wrong. Not me checkingerrnoimmediately π
π ERRORS π
Every single one, no skipping:
EFAULTβ problem with copying information to user space. The copy justβ¦ did not go through πEINVALβ invalidpid. That number is not it.ENOSYSβ the system call is not yet implemented (this one's only on rather old kernels, like vintage vintage π§)ESRCHβ could not find a process with the IDpid. It's not there bestie, it's simply not there π
π VERSIONS π
Linux
Linux 3.9 added a whole new mechanism for adjusting (and viewing) the SCHED_RR quantum: the /proc/sys/kernel/sched_rr_timeslice_ms file exposes the quantum as a millisecond value, and its default is 100. And plot twist β writing 0 to this file resets the quantum to the default value. Iconic behavior honestly β¨
β STANDARDS β
POSIX.1-2024. Certified, standardized, doing it by the book π
π°οΈ HISTORY π°οΈ
POSIX.1-2001. Yes, this has been around a minute.
Linux
so POSIX straight up does not specify any mechanism for controlling the size of the round-robin time quantum. None. Zero. Nada.
Older Linux kernels said "fine, I'll do it myself" and provided a (nonportable β read that again, bestie, nonportable π¨) method of doing this. The quantum could be controlled by adjusting the process's nice value (see setpriority(2)). Here's the tea:
- assigning a negative (i.e., high) nice value results in a longer quantum
- assigning a positive (i.e., low) nice value results in a shorter quantum
The default quantum is 0.1 seconds. And the degree to which changing the nice value affects the quantum has varied somewhat across kernel versions β so it was a bit of a wildcard π²
This method of adjusting the quantum was removed starting with Linux 2.6.24. Gone. Retired. We don't do that anymore πͺ¦
π NOTES π
POSIX systems on which sched_rr_get_interval() is available define _POSIX_PRIORITY_SCHEDULING in <unistd.h>. that's the little signal check you can do so you're not out here calling functions that don't exist π
π SEE ALSO π
and that's the whole page, bestie!! you understood all of it, no cap π«Ά This one's from Linux man-pages 6.20, dated 2026-02-08, and it's still sched_rr_get_interval(2). Go get those time quantums, main character π
πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-2.0-or-later
- Copyright 1996, Tom Bjorkholm <tomb@mydata.se>
- Copyright 1996, Markus Kuhn <mkuhn@acm.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms