1TIMER_CREATE(2) Linux Programmer's Manual TIMER_CREATE(2)
2
3
4
6 timer_create - create a POSIX per-process timer
7
9 #include <signal.h> /* Definition of SIGEV_* constants */
10 #include <time.h>
11
12 int timer_create(clockid_t clockid, struct sigevent *restrict sevp,
13 timer_t *restrict timerid);
14
15 Link with -lrt.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 timer_create():
20 _POSIX_C_SOURCE >= 199309L
21
23 timer_create() creates a new per-process interval timer. The ID of the
24 new timer is returned in the buffer pointed to by timerid, which must
25 be a non-null pointer. This ID is unique within the process, until the
26 timer is deleted. The new timer is initially disarmed.
27
28 The clockid argument specifies the clock that the new timer uses to
29 measure time. It can be specified as one of the following values:
30
31 CLOCK_REALTIME
32 A settable system-wide real-time clock.
33
34 CLOCK_MONOTONIC
35 A nonsettable monotonically increasing clock that measures time
36 from some unspecified point in the past that does not change af‐
37 ter system startup.
38
39 CLOCK_PROCESS_CPUTIME_ID (since Linux 2.6.12)
40 A clock that measures (user and system) CPU time consumed by
41 (all of the threads in) the calling process.
42
43 CLOCK_THREAD_CPUTIME_ID (since Linux 2.6.12)
44 A clock that measures (user and system) CPU time consumed by the
45 calling thread.
46
47 CLOCK_BOOTTIME (Since Linux 2.6.39)
48 Like CLOCK_MONOTONIC, this is a monotonically increasing clock.
49 However, whereas the CLOCK_MONOTONIC clock does not measure the
50 time while a system is suspended, the CLOCK_BOOTTIME clock does
51 include the time during which the system is suspended. This is
52 useful for applications that need to be suspend-aware.
53 CLOCK_REALTIME is not suitable for such applications, since that
54 clock is affected by discontinuous changes to the system clock.
55
56 CLOCK_REALTIME_ALARM (since Linux 3.0)
57 This clock is like CLOCK_REALTIME, but will wake the system if
58 it is suspended. The caller must have the CAP_WAKE_ALARM capa‐
59 bility in order to set a timer against this clock.
60
61 CLOCK_BOOTTIME_ALARM (since Linux 3.0)
62 This clock is like CLOCK_BOOTTIME, but will wake the system if
63 it is suspended. The caller must have the CAP_WAKE_ALARM capa‐
64 bility in order to set a timer against this clock.
65
66 CLOCK_TAI (since Linux 3.10)
67 A system-wide clock derived from wall-clock time but ignoring
68 leap seconds.
69
70 See clock_getres(2) for some further details on the above clocks.
71
72 As well as the above values, clockid can be specified as the clockid
73 returned by a call to clock_getcpuclockid(3) or pthread_getcpu‐
74 clockid(3).
75
76 The sevp argument points to a sigevent structure t