summaryrefslogtreecommitdiffstats
path: root/sys/sys/timers.h
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-10-23 04:22:56 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-10-23 04:22:56 +0000
commitcf50eec401d4d7384b3badbb5929bc33849a5855 (patch)
tree0646598ac68425c9b342b7f7d89ec9d97e5673e1 /sys/sys/timers.h
parent79343f4d094c11448cf9581def4af5ee487e1cb7 (diff)
downloadFreeBSD-src-cf50eec401d4d7384b3badbb5929bc33849a5855.zip
FreeBSD-src-cf50eec401d4d7384b3badbb5929bc33849a5855.tar.gz
Implement POSIX timers. Current only CLOCK_REALTIME and CLOCK_MONOTONIC
clock are supported. I have plan to merge XSI timer ITIMER_REAL and other two CPU timers into the new code, current three slots are available for the XSI timers. The SIGEV_THREAD notification type is not supported yet because our sigevent struct lacks of two member fields: sigev_notify_function sigev_notify_attributes I have found the sigevent is used in AIO, so I won't add the two members unless the AIO code is adjusted.
Diffstat (limited to 'sys/sys/timers.h')
-rw-r--r--sys/sys/timers.h77
1 files changed, 75 insertions, 2 deletions
diff --git a/sys/sys/timers.h b/sys/sys/timers.h
index 2321410..deb7175 100644
--- a/sys/sys/timers.h
+++ b/sys/sys/timers.h
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2005 David Xu <davidxu@freebsd.org>
* Copyright (c) 1994 by Chris Provenzano, proven@mit.edu
* All rights reserved.
*
@@ -37,6 +38,78 @@
#ifndef _SYS_TIMERS_H_
#define _SYS_TIMERS_H_
-#include <sys/time.h>
+/*
+ * Structures used to manage POSIX timers in a process.
+ */
+struct itimer {
+ struct mtx it_mtx;
+ struct sigevent it_sigev;
+ struct itimerval it_time;
+ struct proc *it_proc;
+ int it_flags;
+ int it_usecount;
+ int it_overrun; /* Overruns currently accumulating */
+ int it_overrun_last; /* Overruns associated w/ a delivery */
+ int it_clockid;
+ int it_timerid;
+ ksiginfo_t it_ksi;
+ union {
+ /* realtime */
+ struct {
+ struct callout it_callout;
+ } _rt;
+
+ /* cpu timer */
+ struct {
+ LIST_ENTRY(itimer) it_link;
+ TAILQ_ENTRY(itimer) it_worklink;
+ int it_active;
+ int it_cflags;
+ } _cpu;
+ } _data;
+};
+
+#define it_callout _data._rt.it_callout
+#define it_link _data._cpu.it_link
+#define it_active _data._cpu.it_active
+#define it_worklink _data._cpu.it_worklink
+#define it_cflags _data._cpu.it_cflags
+
+#define ITF_DELETING 0x01
+#define ITF_WANTED 0x02
+
+#define ITCF_ONWORKLIST 0x01
+
+#define TIMER_MAX 32
+
+#define ITIMER_LOCK(it) mtx_lock(&(it)->it_mtx)
+#define ITIMER_UNLOCK(it) mtx_unlock(&(it)->it_mtx)
+
+LIST_HEAD(itimerlist, itimer);
+
+struct itimers {
+ struct itimerlist its_virtual;
+ struct itimerlist its_prof;
+ TAILQ_HEAD(, itimer) its_worklist;
+ struct itimer **its_timers;
+};
+
+struct kclock {
+ int (*timer_create)(struct itimer *timer);
+ int (*timer_settime)(struct itimer * timer, int flags,
+ struct itimerspec * new_value,
+ struct itimerspec * old_value);
+ int (*timer_delete)(struct itimer * timer);
+ int (*timer_gettime)(struct itimer * timer,
+ struct itimerspec * cur_value);
+ void (*event_hook)(struct proc *p, clockid_t clock_id, int event);
+};
+
+/* Event values for event_hook() */
+#define ITIMER_EV_EXEC 0
+#define ITIMER_EV_EXIT 1
+
+void itimers_init(struct itimers *its);
+void itimers_event_hook(struct proc *p, int event);
-#endif
+#endif /* !_SYS_TIMERS_H_ */
OpenPOWER on IntegriCloud