qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Timing problems


From: Sven Zenker
Subject: Re: [Qemu-devel] Timing problems
Date: Sun, 28 Aug 2005 15:23:52 -0400

Hi all,
as a new qemu user, let me first of all say that qemu, especially in
combination with kqemu is a great piece of software. Many thanks to the
developer(s).
Since I am using a Laptop with a Pentium M CPU with SpeedStep and am
forced to use XP SP2 as a guest OS (Suse 9.3 is host OS), it wouldn't
work reliably for me,  for reasons mentioned previously in this thread
(system services timing out at startup, networking problems etc.).
Really needing a working emulator bad, I came up with the following ugly
hack, which leads to a stable and network enabled XP SP 2 running in
qemu on my SpeedStep machine, with the side effect of having an accurate
real time clock in the guest OS again. It simply replaces the virtual
timer mechanism based on CPU tick count (which is totally messed up in a
SpeedStep setting) with calls to the realtime clock. It should work even
when emulation is stopped intermittently, I hope, since the  built in
"virtual clock stop" mechanism ist left unchanged. 
I modified only the I386 code, so to make this work on other machines,
more modifications would be necessary:
++++++++++++++++++++++++++++++++
qemu-0.7.1 # diff vl.c.org vl.c 
503d502
<
505d503
<
508,510c506
<     int64_t val;
<     asm volatile ("rdtsc" : "=A" (val));
<     return val;
---
>     return get_clock();
512d507
<
594,605c589
<     int64_t usec, ticks;
<
<     usec = get_clock();
<     ticks = cpu_get_real_ticks();
< #ifdef _WIN32
<     Sleep(50);
< #else
<     usleep(50 * 1000);
< #endif
<     usec = get_clock() - usec;
<     ticks = cpu_get_real_ticks() - ticks;
<     ticks_per_sec = (ticks * 1000000LL + (usec >> 1)) / usec;
---
>       ticks_per_sec = 1000000LL;  /* our real time clock resolution */

+++++++++++++++++++++++++++++++++

and 

+++++++++++++++++++++++++++++++++

qemu-0.7.1/linux-user # diff main.c.org main.c
113,115c113
<     int64_t val;
<     asm volatile ("rdtsc" : "=A" (val));
<     return val;
---
>     return get_clock();
 return get_clock();
---
>     return val;

++++++++++++++++++++++++++++++
This is of course an ugly hack and sure to affect performance, but at
least, it makes XP work for me.
Please let me know your thoughts.
Best regards,
Sven Zenker

-- 
Dr. med. Sven Zenker
Research Associate
Center for Inflammation and Regenerative Modeling
Dpt. of Critical Care Medicine
University of Pittsburgh Medical Center





reply via email to

[Prev in Thread] Current Thread [Next in Thread]