[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC] [PATCHv5 10/16] aio / timers: aio_ctx_prepare sets ti
From: |
Alex Bligh |
Subject: |
[Qemu-devel] [RFC] [PATCHv5 10/16] aio / timers: aio_ctx_prepare sets timeout from AioContext timers |
Date: |
Sun, 4 Aug 2013 19:09:59 +0100 |
Calculate the timeout in aio_ctx_prepare taking into account
the timers attached to the AioContext.
Alter aio_ctx_check similarly.
Signed-off-by: Alex Bligh <address@hidden>
---
async.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/async.c b/async.c
index c80da2f..8df3e99 100644
--- a/async.c
+++ b/async.c
@@ -123,13 +123,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
{
AioContext *ctx = (AioContext *) source;
QEMUBH *bh;
+ int deadline;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
/* idle bottom halves will be polled at least
* every 10ms */
- *timeout = 10;
+ *timeout = qemu_soonest_timeout(*timeout, 10);
} else {
/* non-idle bottom halves will be executed
* immediately */
@@ -139,6 +140,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
}
}
+ deadline = qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(ctx->tlg));
+ if (deadline == 0) {
+ *timeout = 0;
+ return true;
+ } else {
+ *timeout = qemu_soonest_timeout(*timeout, deadline);
+ }
+
return false;
}
@@ -153,7 +162,7 @@ aio_ctx_check(GSource *source)
return true;
}
}
- return aio_pending(ctx);
+ return aio_pending(ctx) || (timerlistgroup_deadline_ns(ctx->tlg) >= 0);
}
static gboolean
--
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, 2013/08/04
- [Qemu-devel] [RFC] [PATCHv5 10/16] aio / timers: aio_ctx_prepare sets timeout from AioContext timers,
Alex Bligh <=
- [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
- Re: [Qemu-devel] [RFC] [PATCHv5 06/16] aio / timers: Untangle include files, Stefan Hajnoczi, 2013/08/06