[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets tim
From: |
Wenchao Xia |
Subject: |
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers |
Date: |
Tue, 20 Aug 2013 11:08:58 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
δΊ 2013-8-16 4:34, Alex Bligh ει:
> 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 2b9ba9b..d8656cc 100644
> --- a/async.c
> +++ b/async.c
> @@ -150,13 +150,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);
glib will not set *timeout to a meaningful value before calling
aio_ctx_prepare(), right? If so, "*timeout = 10" should be used.
> } else {
> /* non-idle bottom halves will be executed
> * immediately */
> @@ -166,6 +167,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;
> }
>
> @@ -180,7 +189,7 @@ aio_ctx_check(GSource *source)
> return true;
> }
> }
> - return aio_pending(ctx);
> + return aio_pending(ctx) || (timerlistgroup_deadline_ns(&ctx->tlg) == 0);
> }
>
> static gboolean
>
--
Best Regards
Wenchao Xia
- [Qemu-devel] [PATCHv11 06/31] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack, (continued)
- [Qemu-devel] [PATCHv11 06/31] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 07/31] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 05/31] aio / timers: add ppoll support with qemu_poll_ns, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 01/31] aio / timers: Rename qemu_timer_* functions, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 11/31] aio / timers: Add QEMUTimerListGroup to AioContext, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 10/31] aio / timers: Add QEMUTimerListGroup and helper functions, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 09/31] aio / timers: Untangle include files, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 12/31] aio / timers: Add a notify callback to QEMUTimerList, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 14/31] aio / timers: Add aio_timer_init & aio_timer_new wrappers, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/15
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers,
Wenchao Xia <=
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/20
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Wenchao Xia, 2013/08/20
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/20
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Wenchao Xia, 2013/08/20
- Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/20
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Stefan Hajnoczi, 2013/08/21
[Qemu-devel] [PATCHv11 17/31] aio / timers: On timer modification, qemu_notify or aio_notify, Alex Bligh, 2013/08/15
[Qemu-devel] [PATCHv11 16/31] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/15
[Qemu-devel] [PATCHv11 23/31] aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms, Alex Bligh, 2013/08/15