sched.h(7POSIX)
π sched.h(7POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual β this one is sched.h(7POSIX), aka execution scheduling, and it's genuinely one of those headers that runs the whole vibe of your machine. sit down, grab a strawberry drink π, we're doing this.
β¨ PROLOG β¨
okay so first things first, real talk: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the deets on Linux behavior), or β plot twist β the interface may not be implemented on Linux at all. π
π NAME π
sched.h β execution scheduling. that's the whole name. short, iconic, does exactly what it says. π
πΈ SYNOPSIS πΈ
#include <sched.h>
that's it. that's the door. walk through it. πͺβ¨
π¦ DESCRIPTION π¦
okay so here's the tea. the <sched.h> header shall define the pid_t type, exactly as described in <sys/types.h>.
it shall also define the time_t type, as described in <sys/types.h>.
and it shall define the timespec structure, as described in <time.h>.
then we get to the good part: the header shall define the sched_param structure, which shall include the scheduling parameters required for implementation of each supported scheduling policy. this structure shall include at least this member:
int sched_priority Process or thread execution scheduling priority.
and the sched_param structure defined in <sched.h> shall include these members in addition to the ones above β so yes, it's giving expanded edition:
int sched_ss_low_priority Low scheduling priority for
sporadic server.
struct timespec sched_ss_repl_period Replenishment period for
sporadic server.
struct timespec sched_ss_init_budget Initial budget for sporadic server.
int sched_ss_max_repl Maximum pending replenishments for
sporadic server.
so the way this works: every process or thread is controlled by an associated scheduling policy and priority. associated with each policy is a priority range. each policy definition specifies the minimum priority range for that policy. and β important β the priority ranges for each policy may overlap the priority ranges of other policies. no gatekeeping. π
four scheduling policies are defined; others may be defined by the implementation. the four standard policies are indicated by the values of these symbolic constants:
SCHED_FIFOβ first in-first out (FIFO) scheduling policy.SCHED_RRβ round robin scheduling policy.SCHED_SPORADICβ sporadic server scheduling policy.SCHED_OTHERβ another scheduling policy.
the values of these constants are distinct. no two the same, periodt.
the following shall be declared as functions and may also be defined as macros. function prototypes shall be provided:
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_getparam(pid_t, struct sched_param *);
int sched_getscheduler(pid_t);
int sched_rr_get_interval(pid_t, struct timespec *);
int sched_setparam(pid_t, const struct sched_param *);
int sched_setscheduler(pid_t, int, const struct sched_param *);
int sched_yield(void);
lowkey a whole friend group of syscalls right there π«Ά
one more thing: inclusion of the <sched.h> header may make visible all symbols from the <time.h> header. surprise guests at the party. π
the following sections are informative β meaning they're the commentary track, not the actual requirements.
π APPLICATION USAGE π
None.
literally nothing. the void. π
π§ RATIONALE π§
None.
also nothing! the vibes are immaculate and unexplained. β¨
β FUTURE DIRECTIONS β
None.
nothing coming down the pipeline either. it's stable, bestie. πΈ
π₯ SEE ALSO π₯
<sys_types.h><time.h>
and from the System Interfaces volume of POSIX.1β2017:
sched_get_priority_max()sched_getparam()sched_getscheduler()sched_rr_get_interval()sched_setparam()sched_setscheduler()sched_yield()
go read those next, i'm obsessed with them actually. ππ
π COPYRIGHT π
okay legal bestie moment, this part matters so read it fr fr:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
no cap: if this page and the real Standard ever disagree, the Standard wins. it's the referee, not us. π
and that's the page!! this one's brought to you by IEEE/The Open Group, 2017 β the source and the date of this whole thing. ty for coming to my ted talk, now go schedule something responsibly π¦πβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms