From: Paolo Bonzini <pbonzini@redhat.com>
To: jacob.kroon@gmail.com
Cc: Stefan Weil <sw@weilnetz.de>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32
Date: Tue, 09 Apr 2013 18:21:48 +0200 [thread overview]
Message-ID: <5164401C.30008@redhat.com> (raw)
In-Reply-To: <1361367811-13288-3-git-send-email-pbonzini@redhat.com>
Il 20/02/2013 14:43, Paolo Bonzini ha scritto:
> These are needed for any of the Win32 alarm timer implementations.
> They are not tied to mmtimer exclusively.
>
> Jacob tested this patch with both mmtimer and Win32 timers.
>
> Cc: qemu-stable@nongnu.org
> Tested-by: Jacob Kroon <jacob.kroon@gmail.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> Jacob, this is the same as "patch 1" you tested.
Stefan, can you pick up this patch again, together with Fabien's series?
Paolo
> os-win32.c | 10 ++++++++++
> qemu-timer.c | 26 ++++++--------------------
> 2 files changed, 16 insertions(+), 20 deletions(-)
>
> diff --git a/os-win32.c b/os-win32.c
> index 3d43604..a0740ef 100644
> --- a/os-win32.c
> +++ b/os-win32.c
> @@ -23,6 +23,7 @@
> * THE SOFTWARE.
> */
> #include <windows.h>
> +#include <mmsystem.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <signal.h>
> @@ -67,9 +67,19 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
> return TRUE;
> }
>
> +static TIMECAPS mm_tc;
> +
> +static void os_undo_timer_resolution(void)
> +{
> + timeEndPeriod(mm_tc.wPeriodMin);
> +}
> +
> void os_setup_early_signal_handling(void)
> {
> SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE);
> + timeGetDevCaps(&mm_tc, sizeof(mm_tc));
> + timeBeginPeriod(mm_tc.wPeriodMin);
> + atexit(os_undo_timer_resolution);
> }
>
> /* Look for support files in the same directory as the executable. */
> diff --git a/qemu-timer.c b/qemu-timer.c
> index 8fb5c75..50109a1 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -623,29 +622,15 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg,
>
> static int mm_start_timer(struct qemu_alarm_timer *t)
> {
> timeGetDevCaps(&mm_tc, sizeof(mm_tc));
> -
> - timeBeginPeriod(mm_tc.wPeriodMin);
> -
> - mm_timer = timeSetEvent(mm_tc.wPeriodMin, /* interval (ms) */
> - mm_tc.wPeriodMin, /* resolution */
> - mm_alarm_handler, /* function */
> - (DWORD_PTR)t, /* parameter */
> - TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
> -
> - if (!mm_timer) {
> - fprintf(stderr, "Failed to initialize win32 alarm timer\n");
> - timeEndPeriod(mm_tc.wPeriodMin);
> - return -1;
> - }
> -
> return 0;
> }
>
> static void mm_stop_timer(struct qemu_alarm_timer *t)
> {
> - timeKillEvent(mm_timer);
> - timeEndPeriod(mm_tc.wPeriodMin);
> + if (mm_timer) {
> + timeKillEvent(mm_timer);
> + }
> }
>
> static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
> @@ -657,7 +641,9 @@ static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
> nearest_delta_ms = mm_tc.wPeriodMax;
> }
>
> - timeKillEvent(mm_timer);
> + if (mm_timer) {
> + timeKillEvent(mm_timer);
> + }
> mm_timer = timeSetEvent((UINT)nearest_delta_ms,
> mm_tc.wPeriodMin,
> mm_alarm_handler,
>
next parent reply other threads:[~2013-04-09 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1361367811-13288-1-git-send-email-pbonzini@redhat.com>
[not found] ` <1361367811-13288-3-git-send-email-pbonzini@redhat.com>
2013-04-09 16:21 ` Paolo Bonzini [this message]
2013-04-09 20:22 ` [Qemu-devel] [PATCH 2/2] qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32 Stefan Weil
[not found] ` <1361367811-13288-2-git-send-email-pbonzini@redhat.com>
[not found] ` <CAA=zYJbN1RCPwd9hKHacFc8eFMHN=gy-bsDeboGj4yMUpXqpuQ@mail.gmail.com>
[not found] ` <5125D10A.5010609@redhat.com>
[not found] ` <CAA=zYJaUOGOTugjuFpRwBDZW1j5OTpwicMW8RZK_LzQJ_02KJA@mail.gmail.com>
[not found] ` <CAA=zYJbYj9xaG1prgpaA223Ufi16Fj--1J4KFE+=FqrdKgAzRA@mail.gmail.com>
2013-04-10 8:26 ` [Qemu-devel] [PATCH 1/2] win32: do not set CPU affinity Fabien Chouteau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5164401C.30008@redhat.com \
--to=pbonzini@redhat.com \
--cc=jacob.kroon@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.