Debian Codegraph @

upstream/debian-unstable/man2/PR_SET_TIMERSLACK.2const

raw
1 .\" Copyright 2012-2015, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH PR_SET_TIMERSLACK 2const 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 PR_SET_TIMERSLACK
9 \-
10 set the "current" timer slack value for the calling thread
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
17 .B #include <sys/prctl.h>
18 .P
19 .BI "int prctl(PR_SET_TIMERSLACK, unsigned long " slack );
20 .fi
21 .SH DESCRIPTION
22 Each thread has two associated timer slack values:
23 a "default" value, and a "current" value.
24 This operation sets the "current" timer slack value for the calling thread.
25 .I slack
26 is an unsigned long value
27 in the range
28 .RB [ 1L ,
29 .BR ULONG_MAX ].
30 If the nanosecond value supplied in
31 .I slack
32 is greater than zero, then the "current" value is set to this value.
33 If
34 .I slack
35 is
36 .BR 0L ,
37 the "current" timer slack is reset to the
38 thread's "default" timer slack value.
39 .P
40 The "current" timer slack is used by the kernel to
41 group timer expirations
42 for the calling thread
43 that are close to one another;
44 as a consequence, timer expirations for the thread may be
45 up to the specified number of nanoseconds late (but will never expire early).
46 Grouping timer expirations can help reduce system power consumption
47 by minimizing CPU wake-ups.
48 .P
49 The timer expirations affected by timer slack are those set by
50 .BR select (2),
51 .BR pselect (2),
52 .BR poll (2),
53 .BR ppoll (2),
54 .BR epoll_wait (2),
55 .BR epoll_pwait (2),
56 .BR clock_nanosleep (2),
57 .BR nanosleep (2),
58 and
59 .BR futex (2)
60 (and thus the library functions implemented via futexes, including
61 .\" List obtained by grepping for futex usage in glibc source
62 .BR pthread_cond_timedwait (3),
63 .BR pthread_mutex_timedlock (3),
64 .BR pthread_rwlock_timedrdlock (3),
65 .BR pthread_rwlock_timedwrlock (3),
66 and
67 .BR sem_timedwait (3)).
68 .P
69 Timer slack is not applied to threads that are scheduled under
70 a real-time scheduling policy (see
71 .BR sched_setscheduler (2)).
72 .P
73 When a new thread is created,
74 the two timer slack values are made the same as the "current" value
75 of the creating thread.
76 Thereafter, a thread can adjust its "current" timer slack value via
77 .BR PR_SET_TIMERSLACK .
78 The "default" value can't be changed.
79 The timer slack values of
80 .BR init (1)
81 (PID 1), the ancestor of all processes,
82 are 50,000 nanoseconds (50 microseconds).
83 The timer slack value is inherited by a child created via
84 .BR fork (2),
85 and is preserved across
86 .BR execve (2).
87 .SH RETURN VALUE
88 On success,
89 0 is returned.
90 On error, \-1 is returned, and
91 .I errno
92 is set to indicate the error.
93 .SH STANDARDS
94 Linux.
95 .SH HISTORY
96 Linux 2.6.28.
97 .\" See https://lwn.net/Articles/369549/
98 .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
99 .SH SEE ALSO
100 .BR prctl (2),
101 .BR PR_GET_TIMERSLACK (2const),
102 .BR proc_pid_timerslack_ns (5)