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_FIFO
  • SCHED_RR
  • SCHED_OTHER
  • SCHED_BATCH
  • SCHED_IDLE
  • SCHED_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 argument policy does 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 ๐Ÿ‘€


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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms