[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC] [PATCHv5 07/16] aio / timers: Add QEMUTimerListGroup
From: |
Alex Bligh |
Subject: |
[Qemu-devel] [RFC] [PATCHv5 07/16] aio / timers: Add QEMUTimerListGroup and helper functions |
Date: |
Sun, 4 Aug 2013 19:09:56 +0100 |
Add QEMUTimerListGroup and helper functions, to represent
a QEMUTimerList associated with each clock. Add a default
QEMUTimerListGroup representing the default timer lists
which are not associated with any other object (e.g.
an AioContext as added by future patches).
Signed-off-by: Alex Bligh <address@hidden>
---
include/qemu/timer.h | 7 +++++++
qemu-timer.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 9f1ff95..87e7b6e 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -19,8 +19,10 @@ typedef enum {
typedef struct QEMUClock QEMUClock;
typedef struct QEMUTimerList QEMUTimerList;
+typedef QEMUTimerList * QEMUTimerListGroup[QEMU_CLOCK_MAX];
typedef void QEMUTimerCB(void *opaque);
+extern QEMUTimerListGroup qemu_default_tlg;
extern QEMUClock *QEMUClocks[QEMU_CLOCK_MAX];
static inline QEMUClock *qemu_get_clock(QEMUClockType type)
@@ -69,6 +71,11 @@ int64_t timerlist_deadline_ns(QEMUTimerList *tl);
QEMUClock *timerlist_get_clock(QEMUTimerList *tl);
bool timerlist_run_timers(QEMUTimerList *tl);
+void timerlistgroup_init(QEMUTimerListGroup tlg);
+void timerlistgroup_deinit(QEMUTimerListGroup tlg);
+bool timerlistgroup_run_timers(QEMUTimerListGroup tlg);
+int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup tlg);
+
int qemu_timeout_ns_to_ms(int64_t ns);
int qemu_poll_ns(GPollFD *fds, uint nfds, int64_t timeout);
void qemu_clock_enable(QEMUClock *clock, bool enabled);
diff --git a/qemu-timer.c b/qemu-timer.c
index 231953a..1af3b65 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -59,6 +59,7 @@ struct QEMUClock {
bool enabled;
};
+QEMUTimerListGroup qemu_default_tlg;
QEMUClock *QEMUClocks[QEMU_CLOCK_MAX];
/* A QEMUTimerList is a list of timers attached to a clock. More
@@ -569,6 +570,45 @@ bool qemu_run_timers(QEMUClock *clock)
return timerlist_run_timers(clock->default_timerlist);
}
+void timerlistgroup_init(QEMUTimerListGroup tlg)
+{
+ QEMUClockType clock;
+ for (clock = 0; clock < QEMU_CLOCK_MAX; clock++) {
+ tlg[clock] = timerlist_new(clock);
+ }
+}
+
+void timerlistgroup_deinit(QEMUTimerListGroup tlg)
+{
+ QEMUClockType clock;
+ for (clock = 0; clock < QEMU_CLOCK_MAX; clock++) {
+ timerlist_free(tlg[clock]);
+ }
+}
+
+bool timerlistgroup_run_timers(QEMUTimerListGroup tlg)
+{
+ QEMUClockType clock;
+ bool progress = false;
+ for (clock = 0; clock < QEMU_CLOCK_MAX; clock++) {
+ progress |= timerlist_run_timers(tlg[clock]);
+ }
+ return progress;
+}
+
+int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup tlg)
+{
+ int64_t deadline = -1;
+ QEMUClockType clock;
+ for (clock = 0; clock < QEMU_CLOCK_MAX; clock++) {
+ if (qemu_clock_use_for_deadline(tlg[clock]->clock)) {
+ deadline = qemu_soonest_timeout(deadline,
+ timerlist_deadline_ns(tlg[clock]));
+ }
+ }
+ return deadline;
+}
+
int64_t qemu_get_clock_ns(QEMUClock *clock)
{
int64_t now, last;
@@ -610,6 +650,7 @@ void init_clocks(void)
for (type = 0; type < QEMU_CLOCK_MAX; type++) {
if (!QEMUClocks[type]) {
QEMUClocks[type] = qemu_new_clock(type);
+ qemu_default_tlg[type] = QEMUClocks[type]->default_timerlist;
}
}
--
1.7.9.5
- Re: [Qemu-devel] [RFC] [PATCHv4 10/13] aio / timers: Convert mainloop to use timeout, Paolo Bonzini, 2013/08/01
- Re: [Qemu-devel] [RFC] [PATCHv4 10/13] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/01
- Re: [Qemu-devel] [RFC] [PATCHv4 10/13] aio / timers: Convert mainloop to use timeout, Paolo Bonzini, 2013/08/01
- Re: [Qemu-devel] [RFC] [PATCHv4 10/13] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/02
- [Qemu-devel] [RFC] [PATCHv5 00/16] aio / timers: Add AioContext timers and use ppoll, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 01/16] aio / timers: add qemu-timer.c utility functions, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 04/16] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 07/16] aio / timers: Add QEMUTimerListGroup and helper functions,
Alex Bligh <=
- [Qemu-devel] [RFC] [PATCHv5 10/16] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 08/16] aio / timers: Add QEMUTimerListGroup to AioContext, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 13/16] aio / timers: On timer modification, qemu_notify or aio_notify, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 12/16] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 02/16] aio / timers: add ppoll support with qemu_poll_ns, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 11/16] aio / timers: Convert aio_poll to use AioContext timers' deadline, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 03/16] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 14/16] aio / timers: Use all timerlists in icount warp calculations, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 05/16] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList, Alex Bligh, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 06/16] aio / timers: Untangle include files, Alex Bligh, 2013/08/04