This is the new timerfd API as it is implemented by the following patch:
int timerfd_create(int clockid);
int timerfd_settime(int ufd, int flags,
const struct itimerspec *utmr,
struct itimerspec *otmr);
int timerfd_gettime(int ufd, struct itimerspec *otmr);
The timerfd_create() API creates an un-programmed timerfd fd. The "clockid"
parameter can be either CLOCK_MONOTONIC or CLOCK_REALTIME.
The timerfd_settime() API give new settings by the timerfd fd, by optionally
retrieving the previous expiration time (in case the "otmr" parameter is not NULL).
The time value specified in "utmr" is absolute, if the TFD_TIMER_ABSTIME bit
is set in the "flags" parameter. Otherwise it's a relative time.
The timerfd_gettime() API returns the next expiration time of the timer, or {0, 0}
if the timerfd has not been set yet.
Like the previous timerfd API implementation, read(2) and poll(2) are supported
(with the same interface).
Here's a simple test program I used to exercise the new timerfd APIs:
http://www.xmailserver.org/timerfd-test2.c
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
- Davide
---
fs/compat.c | 32 ++++++-
fs/timerfd.c | 199 ++++++++++++++++++++++++++++++-----------------
include/linux/compat.h | 7 +
include/linux/syscalls.h | 7 +
4 files changed, 168 insertions(+), 77 deletions(-)
Index: linux-2.6.mod/fs/timerfd.c
===================================================================
--- linux-2.6.mod.orig/fs/timerfd.c 2007-09-23 15:18:09.000000000 -0700
+++ linux-2.6.mod/fs/timerfd.c 2007-09-23 15:25:55.000000000 -0700
@@ -23,15 +23,17 @@
struct timerfd_ctx {
struct hrtimer tmr;
+ int clockid;
ktime_t tintv;
wait_queue_head_t wqh;
int expired;
+ u64 ticks;
};
/*
* This gets called when the timer event triggers. We set the "expired"
* flag, but we do not re-arm the timer (in case it's necessary,
- * tintv.tv64 != 0) until the timer is read.
+ * tintv.tv64 != 0) until...Davide,
Can you please restructure the struct in a way which does not result in
padding by the compiler ?
struct timerfd_ctx {
struct hrtimer tmr;
ktime_t tintv;
wait_queue_head_t wqh;
u64 ticks;
int expired;
int clockid;
You need to use ctx->tmr.base->get_time() here, otherwise you might read
You really can avoid the goto here.
tglx
-Is the particular position of hrtimer_cb_get_time() in the code that would break here? Because function was added by your patch ;) Ack. - Davide -
For non high res systems we speed up the access to now by storing the current time when we start to process the hrtimer softirq callbacks. hrtimer_cb_get_time(timer) reads timer->base->now For high resolution systems hrtimer_cb_get_time() resolves to timer->base->get_time(). In the timerfd case we are not in softirq context and we read at any given later time. Also on SMP the base->now variable might be changed by the softirq running on the other CPU. tglx -
| Eric Paris | TALPA - a threat model? well sorta. |
| Ingo Molnar | [git pull] scheduler updates |
| Karl Meyer | PROBLEM: 2.6.23-rc "NETDEV WATCHDOG: eth0: transmit timed out" |
| Robert Hancock | Re: 2.6.28-rc2 hates my e1000e |
git: | |
| Tomash Brechko | Re: GIT vs Other: Need argument |
| Shawn O. Pearce | libgit2 - a true git library |
| Aubrey Li | git proxy issue |
| Scott Chacon | [PATCH] add a 'pre-push' hook |
| Jordi Espasa Clofent | Editing C with... |
| Julien TOUCHE | setting up ssh tunnel/vpn |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| debian developer | Doubt about license |
| Jim Winstead Jr. | Re: Root Disk/Book Disk Compatibility |
| Robert Blum | Re:help again and again |
| Qi Xia | Re: inode limit ? |
| Drew Eckhardt | bootsector.S @X patch |
