text
stringlengths 0
234
|
---|
these system calls are linux-specific. |
.sh notes |
suppose the following scenario for |
.br clock_realtime |
or |
.br clock_realtime_alarm |
timer that was created with |
.br timerfd_create (): |
.ip (a) 4 |
the timer has been started |
.rb ( timerfd_settime ()) |
with the |
.br tfd_timer_abstime |
and |
.br tfd_timer_cancel_on_set |
flags; |
.ip (b) |
a discontinuous change (e.g., |
.br settimeofday (2)) |
is subsequently made to the |
.br clock_realtime |
clock; and |
.ip (c) |
the caller once more calls |
.br timerfd_settime () |
to rearm the timer (without first doing a |
.br read (2) |
on the file descriptor). |
.pp |
in this case the following occurs: |
.ip \(bu 2 |
the |
.br timerfd_settime () |
returns \-1 with |
.i errno |
set to |
.br ecanceled . |
(this enables the caller to know that the previous timer was affected |
by a discontinuous change to the clock.) |
.ip \(bu |
the timer |
.i "is successfully rearmed" |
with the settings provided in the second |
.br timerfd_settime () |
call. |
(this was probably an implementation accident, but won't be fixed now, |
in case there are applications that depend on this behaviour.) |
.sh bugs |
currently, |
.\" 2.6.29 |
.br timerfd_create () |
supports fewer types of clock ids than |
.br timer_create (2). |
.sh examples |
the following program creates a timer and then monitors its progress. |
the program accepts up to three command-line arguments. |
the first argument specifies the number of seconds for |
the initial expiration of the timer. |
the second argument specifies the interval for the timer, in seconds. |
the third argument specifies the number of times the program should |
allow the timer to expire before terminating. |
the second and third command-line arguments are optional. |
.pp |
the following shell session demonstrates the use of the program: |
.pp |
.in +4n |
.ex |
.rb "$" " a.out 3 1 100" |
0.000: timer started |
3.000: read: 1; total=1 |
4.000: read: 1; total=2 |
.br "\(haz " " # type control\-z to suspend the program" |
[1]+ stopped ./timerfd3_demo 3 1 100 |
.rb "$ " "fg" " # resume execution after a few seconds" |
a.out 3 1 100 |
9.660: read: 5; total=7 |
10.000: read: 1; total=8 |
11.000: read: 1; total=9 |
.br "\(hac " " # type control\-c to suspend the program" |
.ee |
.in |
.ss program source |
\& |
.ex |
.\" the commented out code here is what we currently need until |
.\" the required stuff is in glibc |
.\" |
.\" |
.\"/* link with \-lrt */ |
.\"#define _gnu_source |
.\"#include <sys/syscall.h> |
.\"#include <unistd.h> |
.\"#include <time.h> |
.\"#if defined(__i386__) |
.\"#define __nr_timerfd_create 322 |
.\"#define __nr_timerfd_settime 325 |
.\"#define __nr_timerfd_gettime 326 |
.\"#endif |
.\" |
.\"static int |