PR_SET_TIMERSLACK(2const)
π PR_SET_TIMERSLACK β bestie edition β¨
okay so you know how the <pink>prctl(2)</pink> girlies have a whole alphabet of PR_* constants and you're standing there like "which one do I even use"? well. this is a 2const page, meaning it's one of those little constant-specific manual pages that live under the <purple>Linux man-pages 6.20</purple> umbrella. it's for the C library, standard C library (libc, -lc), and today we're talking about PR_SET_TIMERSLACK, which sets the "current" timer slack value for the calling thread. yes. that's the whole vibe. let's get into it. π¦
πΈ SYNOPSIS πΈ
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_TIMERSLACK, unsigned long slack);
that's it. one call. one unsigned long. iconic honestly. π
β¨ DESCRIPTION β¨
so, every single thread out here carries two associated timer slack values β a "default" value and a "current" value. two. like a main character and a backup dancer. π
This operation β <hotpink>PR_SET_TIMERSLACK</hotpink> β sets the "current" timer slack value for the calling thread. slack is an unsigned long value in the range [1L, ULONG_MAX]. not 0 as a value, bestie, we'll get to that. π
- if the nanosecond value supplied in
slackis greater than zero, then the "current" value gets set to this value. slay. - if
slackis0L, the "current" timer slack is reset to the thread's "default" timer slack value. so0is basically the "no thoughts head empty, go back to factory settings" move. π
π§ what timer slack even does
The "current" timer slack is what the kernel uses to group timer expirations for the calling thread that are close to one another. consequence? timer expirations for the thread may be up to the specified number of nanoseconds late β but they will never expire early. periodt. π₯
and likeβ¦ that grouping is not a bug, it's the whole point: grouping timer expirations can help reduce system power consumption by minimizing CPU wake-ups. your laptop's battery said thank you. πβ¨
π which timers are affected
The timer expirations affected by timer slack are those set by:
select(2)pselect(2)poll(2)ppoll(2)epoll_wait(2)epoll_pwait(2)clock_nanosleep(2)nanosleep(2)futex(2)β and thus the library functions implemented via futexes, including:
β οΈ but catch this: timer slack is not applied to threads that are scheduled under a real-time scheduling policy (see sched_setscheduler(2)). RT threads said "I don't do slack" and honestly, respect. π
π«Ά inheritance & the lore
When a new thread is created, the two timer slack values are made the same as the "current" value of the creating thread. (not the default β the current. inheritance is messy like that. π)
Thereafter, a thread can adjust its "current" timer slack value via <hotpink>PR_SET_TIMERSLACK</hotpink>. but β and this is the plot twist β the "default" value can't be changed. it simply cannot. it's immutable. it's giving "untouchable." π
The timer slack values of init(1) (PID 1), the ancestor of all processes, are 50,000 nanoseconds (50 microseconds). yeah the origin of all life runs at 50 microseconds of slack. beautiful.
The timer slack value is:
so it just keeps travelling down the family tree. generational trauma but make it scheduling. πΈ
π RETURN VALUE π
- On success,
0is returned. π - On error,
-1is returned, anderrnois set to indicate the error.
classic. the eternal binary. no notes. β¨
β STANDARDS β
Linux. that's it, that's the standard. π§ (Linux-specific, bestie β this is not POSIX and never claimed to be.)
π HISTORY π
Linux 2.6.28. old enough to have a driver's license but still cute. π
π¦ SEE ALSO π¦
and that's the whole page, bestie. go set some timer slack, be kind to your CPU, minimize those wake-ups. ππ
this has been the PR_SET_TIMERSLACK(2const) page from Linux man-pages 6.20, dated 2026-02-08 β mwah, take care of yourselves out there, drink water, and remember: timer expirations can be late but they will never be early. ππ«Ά
π¦ 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: Linux-man-pages-copyleft
- Copyright 2012-2015, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms