sched_get_priority_max(2)
๐ sched_get_priority_max(2) โ the System Calls Manual girlies' edition ๐
okay bestie so this is a page from the System Calls Manual (that's section 2, iykyk) and it's all about sched_get_priority_max and its lil sibling sched_get_priority_min. two functions, one job: telling you the priority range. slay.
โจ NAME โจ
sched_get_priority_max, sched_get_priority_min โ get static priority range ๐
๐ LIBRARY ๐
Standard C library, aka libc, link it with -lc. no cap.
๐ฆ SYNOPSIS ๐ฆ
#include <sched.h>
int sched_get_priority_max(int policy);
int sched_get_priority_min(int policy);
look at that. two lil ints in, two lil ints out. iconic.
๐ DESCRIPTION ๐
so, the vibes: sched_get_priority_max() hands you back the maximum priority value you can use with the scheduling algorithm that the policy argument identifies. sched_get_priority_min() does the same thing but for the minimum priority value. same policy, opposite end of the range. bestie behavior.
the policy values that are supported are:
SCHED_FIFOSCHED_RRSCHED_OTHERSCHED_BATCHSCHED_IDLESCHED_DEADLINE
if you want the whole lore on what each of those policies actually does, go read sched(7). it's giving required reading.
kay so here's the key thing to internalize: processes with numerically higher priority values get scheduled before processes with numerically lower priority values. so obviously the value from sched_get_priority_max() is gonna be greater than the value from sched_get_priority_min(). that's just math, bestie. ๐
on Linux, the static priority range is 1 to 99 for the SCHED_FIFO and SCHED_RR policies, and priority 0 for all the remaining policies. and no, you cannot alter the scheduling priority ranges for the various policies. they're locked in. periodt. ๐
now here's the portable-apps tea โ the range of scheduling priorities may vary on other POSIX systems. so if you want your app to work everywhere, the good move is to use a virtual priority range and map it onto the interval you got from sched_get_priority_max() and sched_get_priority_min(). and btw, POSIX.1 requires a spread of at least 32 between the maximum and the minimum values for SCHED_FIFO and SCHED_RR. so no teeny tiny ranges, okay?
oh and one more: POSIX systems where sched_get_priority_max() and sched_get_priority_min() are available define _POSIX_PRIORITY_SCHEDULING in <unistd.h>. that's your little signal that the functions exist. a vibe check, if you will. ๐
๐ RETURN VALUE ๐
on success, sched_get_priority_max() and sched_get_priority_min() return the maximum/minimum priority value for the named scheduling policy. yay!! ๐ซถ
on error, -1 is returned, and errno is set to indicate the error. so like, check your errno bestie, don't just stare at the -1. ๐ญ
๐ ERRORS ๐
EINVALโ the argumentpolicydoes not identify a defined scheduling policy. basically you passed it something that isn't on the list. it's not a vibe, it's an error.
โญ STANDARDS โญ
POSIX.1-2024. we stan a modern standard.
๐ธ HISTORY ๐ธ
POSIX.1-2001. it's been here since the early 2000s and it's still eating, honestly.
๐ SEE ALSO ๐
sched_getaffinity(2)sched_getparam(2)sched_getscheduler(2)sched_setaffinity(2)sched_setparam(2)sched_setscheduler(2)sched(7)
and that's the whole page, bestie!! mwah ๐ this was Linux man-pages 6.20, dated 2026-02-08 โ go drink some water, go check your priorities (literally, via sched_get_priority_max()), and stay iconic. bye!! ๐โจ๐ฆ
๐ฆ 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