SCHED_GET_PRIORITY_MAX(2)

✨ sched_get_priority_max β€” bestie edition ✨

okay so this is sched_get_priority_max(2) from the System Calls Manual, section 2, and it's literally the cheat sheet for how extreme can my scheduling priority even get. no cap.


πŸ’– NAME πŸ’–

sched_get_priority_max, sched_get_priority_min, sched_rr_get_interval β€” get scheduling parameter limits 🎚️

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” the classic, the icon, the one you already linked.

🫢 SYNOPSIS 🫢

#include <sched.h>

int
sched_get_priority_max(int policy);

int
sched_get_priority_min(int policy);

int
sched_rr_get_interval(pid_t pid, struct timespec *interval);

🌸 DESCRIPTION 🌸

so here's the tea. sched_get_priority_max() and sched_get_priority_min() are the little system calls that hand you the appropriate maximum or appropriate minimum (respectively, bestie, don't mix them up πŸ’…) for whatever scheduling policy you passed in as policy.

then there's sched_rr_get_interval() πŸ¦‹ β€” it updates the timespec structure that interval points at so it holds the current execution time limit (aka the time quantum, the lil slice of CPU time it gets before it's politely asked to share) for the process specified by pid. and if pid is zero? πŸŽ€ boom, you get the current execution time limit for the calling process itself. main character energy, honestly.

the value of policy should be one of the scheduling policy values defined in <sched.h>:

  • [SCHED_FIFO] β€” first-in-first-out fixed priority scheduling with no round robin scheduling. it's giving "I was here first and I'm staying." πŸ‘‘
  • [SCHED_OTHER] β€” the standard time sharing scheduler. the normal one, the default one, the vanilla latte of schedulers. β˜•
  • [SCHED_RR] β€” round-robin scheduling across same priority processes. everyone gets a turn, we love fairness ✨

πŸ”₯ RETURN VALUES πŸ”₯

if it goes well, sched_get_priority_max() and sched_get_priority_min() shall return the appropriate maximum or minimum values, respectively. slay. πŸŽ‰

if it does not go well, they shall return a value of -1 and set errno to indicate the error. it's giving heartbreak πŸ’€

the sched_rr_get_interval() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. same vibe, different function. 😭


πŸ’€ ERRORS πŸ’€

on failure errno will be set to the corresponding value:

  • [EINVAL] β€” the value of the policy argument does not represent a defined scheduling policy. bestie that's not a real policy, where did you even find that πŸ™ˆ
  • [ENOSYS] β€” the sched_get_priority_max(), sched_get_priority_min(), and sched_rr_get_interval() system calls are not supported by the implementation. the implementation said "not me" πŸ’…
  • [ESRCH] β€” no process can be found corresponding to that specified by pid. ghosted. literally no such process. πŸ‘»

πŸ‘€ SEE ALSO πŸ‘€

sched_getparam(2), sched_getscheduler(2), sched_setparam(2), sched_setscheduler(2) β€” go read the whole squad, iykyk 🫢


⭐ STANDARDS ⭐

the sched_get_priority_max(), sched_get_priority_min(), and sched_rr_get_interval() system calls conform to IEEE Std 1003.1b-1993 ("POSIX.1"). certified, official, notarized. periodt. πŸ’œ


that's the whole page bestie, every flag, every error, every value, nothing skipped πŸŽ€

this cutie came out of Debian on March 12, 1998, filed under SCHED_GET_PRIORITY_MAX(2) β€” take care of her, she's been iconic since the 90s πŸ’–βœ¨

πŸ“¦ where this page comes from