diff mbox

[2/7] implement win32 dynticks timer

Message ID 1297359464-9789-3-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Feb. 10, 2011, 5:37 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Weil <weil@mail.berlios.de>
Cc: Blue Swirl <blauwirbel@gmail.com>
---
 qemu-timer.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

Blue Swirl Feb. 20, 2011, 9:15 p.m. UTC | #1
On Thu, Feb 10, 2011 at 7:37 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Stefan Weil <weil@mail.berlios.de>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> ---
>  qemu-timer.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-timer.c b/qemu-timer.c
> index b0db780..42960de 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -1006,6 +1006,7 @@ static void win32_stop_timer(struct qemu_alarm_timer *t)
>  static void win32_rearm_timer(struct qemu_alarm_timer *t)
>  {
>     struct qemu_alarm_win32 *data = t->priv;
> +    int nearest_delta_ms;
>
>     assert(alarm_has_dynticks(t));
>     if (!active_timers[QEMU_CLOCK_REALTIME] &&
> @@ -1015,7 +1016,10 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
>
>     timeKillEvent(data->timerId);
>
> -    data->timerId = timeSetEvent(1,
> +    nearest_delta_ms = (qemu_next_alarm_deadline() + 999999) / 1000000;
> +    if (nearest_delta_ms < 1)
> +       nearest_delta_ms = 1;

Braces, please.
Paolo Bonzini Feb. 21, 2011, 8:07 a.m. UTC | #2
On 02/20/2011 10:15 PM, Blue Swirl wrote:
> On Thu, Feb 10, 2011 at 7:37 PM, Paolo Bonzini<pbonzini@redhat.com>  wrote:
>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>> Cc: Stefan Weil<weil@mail.berlios.de>
>> Cc: Blue Swirl<blauwirbel@gmail.com>
>> ---
>>   qemu-timer.c |    6 +++++-
>>   1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/qemu-timer.c b/qemu-timer.c
>> index b0db780..42960de 100644
>> --- a/qemu-timer.c
>> +++ b/qemu-timer.c
>> @@ -1006,6 +1006,7 @@ static void win32_stop_timer(struct qemu_alarm_timer *t)
>>   static void win32_rearm_timer(struct qemu_alarm_timer *t)
>>   {
>>      struct qemu_alarm_win32 *data = t->priv;
>> +    int nearest_delta_ms;
>>
>>      assert(alarm_has_dynticks(t));
>>      if (!active_timers[QEMU_CLOCK_REALTIME]&&
>> @@ -1015,7 +1016,10 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
>>
>>      timeKillEvent(data->timerId);
>>
>> -    data->timerId = timeSetEvent(1,
>> +    nearest_delta_ms = (qemu_next_alarm_deadline() + 999999) / 1000000;
>> +    if (nearest_delta_ms<  1)
>> +       nearest_delta_ms = 1;
>
> Braces, please.

Oops, checkpatch missed it.  Will fix.

Paolo
diff mbox

Patch

diff --git a/qemu-timer.c b/qemu-timer.c
index b0db780..42960de 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -1006,6 +1006,7 @@  static void win32_stop_timer(struct qemu_alarm_timer *t)
 static void win32_rearm_timer(struct qemu_alarm_timer *t)
 {
     struct qemu_alarm_win32 *data = t->priv;
+    int nearest_delta_ms;
 
     assert(alarm_has_dynticks(t));
     if (!active_timers[QEMU_CLOCK_REALTIME] &&
@@ -1015,7 +1016,10 @@  static void win32_rearm_timer(struct qemu_alarm_timer *t)
 
     timeKillEvent(data->timerId);
 
-    data->timerId = timeSetEvent(1,
+    nearest_delta_ms = (qemu_next_alarm_deadline() + 999999) / 1000000;
+    if (nearest_delta_ms < 1)
+	nearest_delta_ms = 1;
+    data->timerId = timeSetEvent(nearest_delta_ms,
                         data->period,
                         host_alarm_handler,
                         (DWORD)t,